Skip to content

all: add Minimum Supported Rust Version (MSRV) #305

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ members = [
repository = "https://github.com/rustcoreutils/posixutils-rs"
license = "MIT"
edition = "2021"
rust-version = "1.77.0"

[workspace.dependencies]
clap = { version = "4", default-features = false, features = ["std", "derive", "help", "usage", "error-context", "cargo"] }
Expand All @@ -42,3 +43,5 @@ errno = "0.3"

[workspace.lints]

[workspace.lints.clippy]
incompatible_msrv = "warn"
16 changes: 14 additions & 2 deletions awk/src/interpreter/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1954,10 +1954,22 @@ pub fn interpret(
.get_mut()
.value = AwkValueVariant::String(maybe_numeric_string(arg.clone()));

// TODO
// MSRV
// First branch
let mut stdin_record_reader: StdinRecordReader;

// Second branch
let mut file_stream: FileStream;

let reader: &mut dyn RecordReader = if arg.as_str() == "-" {
&mut StdinRecordReader::default()
stdin_record_reader = StdinRecordReader::default();

&mut stdin_record_reader
} else {
&mut FileStream::open(&arg)?
file_stream = FileStream::open(&arg)?;

&mut file_stream
};

// at this point we know that some input will be read
Expand Down
28 changes: 26 additions & 2 deletions awk/src/program.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,12 +139,23 @@ pub struct SourceLocation {
pub column: u32,
}

#[derive(Debug, PartialEq, Default)]
#[derive(Debug, PartialEq)]
pub struct DebugInfo {
pub file: Rc<str>,
pub source_locations: Vec<SourceLocation>,
}

// TODO
// MSRV
impl Default for DebugInfo {
fn default() -> Self {
DebugInfo {
file: Rc::from(""),
source_locations: Default::default(),
}
}
}

#[derive(Debug, PartialEq)]
pub struct Action {
pub instructions: Vec<OpCode>,
Expand All @@ -164,14 +175,27 @@ pub struct AwkRule {
pub action: Action,
}

#[derive(Debug, PartialEq, Default)]
#[derive(Debug, PartialEq)]
pub struct Function {
pub name: Rc<str>,
pub parameters_count: usize,
pub instructions: Vec<OpCode>,
pub debug_info: DebugInfo,
}

// TODO
// MSRV
impl Default for Function {
fn default() -> Self {
Function {
name: Rc::from(""),
parameters_count: Default::default(),
instructions: Default::default(),
debug_info: Default::default(),
}
}
}

pub struct Program {
pub constants: Vec<Constant>,
pub globals_count: usize,
Expand Down
1 change: 1 addition & 0 deletions clippy.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
msrv = "1.77.0"
35 changes: 32 additions & 3 deletions ftw/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -794,9 +794,18 @@ where
// Depth first traversal main loop
'outer: while let Some(current) = stack.last() {
let dir = &current.dir;

// TODO
// MSRV
let file_descriptor: FileDescriptor;

let dir_fd = match dir {
HybridDir::Owned(dir) => dir.file_descriptor(),
HybridDir::Deferred(dir) => &dir.open_file_descriptor(),
HybridDir::Deferred(dir) => {
file_descriptor = dir.open_file_descriptor();

&file_descriptor
}
};

// Resize `path_stack` to the appropriate depth.
Expand All @@ -820,13 +829,23 @@ where
// Errors in reading the entry usually occurs due to lack of permissions
Err(e) => {
let second_last_index = stack.len().checked_sub(2);

// TODO
// MSRV
let file_descriptor: FileDescriptor;

let prev_dir = match second_last_index {
Some(index) => match &stack.get(index).unwrap().dir {
HybridDir::Owned(dir) => dir.file_descriptor(),
HybridDir::Deferred(dir) => &dir.open_file_descriptor(),
HybridDir::Deferred(dir) => {
file_descriptor = dir.open_file_descriptor();

&file_descriptor
}
},
None => &starting_dir,
};

err_reporter(
Entry::new(
prev_dir,
Expand Down Expand Up @@ -958,13 +977,23 @@ where
path_stack.pop();

let second_last_index = stack.len().checked_sub(2);

// TODO
// MSRV
let file_descriptor: FileDescriptor;

let prev_dir = match second_last_index {
Some(index) => match &stack.get(index).unwrap().dir {
HybridDir::Owned(dir) => dir.file_descriptor(),
HybridDir::Deferred(dir) => &dir.open_file_descriptor(),
HybridDir::Deferred(dir) => {
file_descriptor = dir.open_file_descriptor();

&file_descriptor
}
},
None => &starting_dir,
};

if postprocess_dir(Entry::new(
prev_dir,
&path_stack,
Expand Down
33 changes: 26 additions & 7 deletions m4/src/output.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
use crate::{error::Result, input::InputStateRef, state::StackFrame};
use std::{
cell::RefCell,
cell::{RefCell, RefMut},
io::{Seek, Write},
ops::DerefMut,
rc::Rc,
};

Expand Down Expand Up @@ -195,15 +196,33 @@ impl TryFrom<usize> for DivertBufferNumber {

impl Write for Output {
fn write(&mut self, buf: &[u8]) -> std::io::Result<usize> {
let output: &mut dyn Write = match self.divert_number {
0 => &mut *self.stdout.borrow_mut(),
// TODO
// MSRV
// First branch
let rc: Rc<RefCell<dyn Write>>;

let mut dyn_write_ref_mut: RefMut<dyn Write>;

// Second branch
let mut divertable_buffer_ref_mut: RefMut<DivertableBuffer>;

let output = match self.divert_number {
0 => {
rc = self.stdout();

dyn_write_ref_mut = rc.borrow_mut();

dyn_write_ref_mut.deref_mut()
}
1..=9 => {
&mut self.divert_buffers[self
let divert_buffers_index = self
.divert_buffer_number()
.expect("valid divert buffer number")
.index()]
.borrow_mut()
.0
.index();

divertable_buffer_ref_mut = self.divert_buffers[divert_buffers_index].borrow_mut();

&mut divertable_buffer_ref_mut.0
}
i if i < 0 => return Ok(buf.len()),
_ => unreachable!("unreachable, was checked in Self::divert()"),
Expand Down
8 changes: 7 additions & 1 deletion pathnames/realpath.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,16 @@ struct Args {
fn normalize<P: AsRef<Path>>(path: P) -> std::io::Result<PathBuf> {
let mut out = PathBuf::new();

// TODO
// MSRV
let path_buf: PathBuf;

let abs_path = if path.as_ref().is_absolute() {
path.as_ref()
} else {
&std::env::current_dir()?.join(path)
path_buf = std::env::current_dir()?.join(path);

&path_buf
};

// from cargo/src/cargo/util/paths.rs
Expand Down
11 changes: 10 additions & 1 deletion tree/mv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -288,10 +288,19 @@ fn move_file(
.map_err(err_inter_device)?;
}

// TODO
// MSRV
let mut hash_set: HashSet<PathBuf>;

let created_files = match created_files {
Some(set) => set,
None => &mut HashSet::new(),
None => {
hash_set = HashSet::<PathBuf>::new();

&mut hash_set
}
};

copy_hierarchy(cfg, source, target, inode_map, created_files).map_err(err_inter_device)?;

Ok(false)
Expand Down
19 changes: 12 additions & 7 deletions users/talk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ use libc::{
sockaddr_in, winsize, AF_INET, AI_CANONNAME, SIGINT, SIGPIPE, SIGQUIT, SOCK_DGRAM,
STDIN_FILENO, STDOUT_FILENO, TIOCGWINSZ,
};

use std::{
char,
ffi::{CStr, CString},
Expand All @@ -31,7 +30,7 @@ use std::{
},
os::fd::AsRawFd,
process, ptr,
sync::{Arc, LazyLock, Mutex},
sync::{Arc, Mutex, OnceLock},
thread,
time::{Duration, Instant},
};
Expand All @@ -53,9 +52,15 @@ pub struct State {
pub talkd_addr: SocketAddr,
}

/// A static variable to hold the state of delete invitations on SIGINT signal.
static DELETE_INVITATIONS: LazyLock<Arc<Mutex<Option<State>>>> =
LazyLock::new(|| Arc::new(Mutex::new(None)));
// TODO
// MSRV
fn get_delete_invitations() -> &'static Arc<Mutex<Option<State>>> {
/// A static variable to hold the state of delete invitations on SIGINT signal.
static DELETE_INVITATIONS: OnceLock<Arc<Mutex<Option<State>>>> =
OnceLock::<Arc<Mutex<Option<State>>>>::new();

DELETE_INVITATIONS.get_or_init(|| Arc::new(Mutex::new(None)))
}

/// The size of the buffer for control message fields like l_name, r_name, and r_tty in CtlMsg.
const BUFFER_SIZE: usize = 12;
Expand Down Expand Up @@ -959,7 +964,7 @@ fn handle_new_invitation(

let clone_socket = Arc::clone(&socket);

*DELETE_INVITATIONS.lock().unwrap() = Some(State {
*get_delete_invitations().lock().unwrap() = Some(State {
msg_bytes1,
msg_bytes2,
socket: clone_socket,
Expand Down Expand Up @@ -1627,7 +1632,7 @@ pub fn handle_signals(signal_code: libc::c_int) {
eprintln!("Connection closed, exiting...");

// Lock the DELETE_INVITATIONS mutex and check for an existing invitation
if let Some(state) = DELETE_INVITATIONS.lock().unwrap().as_ref() {
if let Some(state) = get_delete_invitations().lock().unwrap().as_ref() {
// Handle the deletion of invitations
handle_delete_invitations(&state.socket, &state.msg_bytes1, &state.talkd_addr);
handle_delete_invitations(&state.socket, &state.msg_bytes2, &state.talkd_addr);
Expand Down