Skip to content

Commit

Permalink
Drop some nightly features (#15)
Browse files Browse the repository at this point in the history
Signed-off-by: Alex Saveau <saveau.alexandre@gmail.com>
  • Loading branch information
SUPERCILEX committed Mar 26, 2023
1 parent dd77f17 commit bbbfe20
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 25 deletions.
3 changes: 0 additions & 3 deletions fuc_engine/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
#![feature(const_cstr_methods)]
#![feature(const_result_drop)]
#![feature(const_option)]
#![feature(once_cell)]
#![allow(clippy::module_name_repetitions)]

Expand Down
19 changes: 11 additions & 8 deletions fuc_engine/src/ops/copy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -233,17 +233,18 @@ mod compat {

let mut raw_dir = RawDir::new(&from_dir, buf);
while let Some(file) = raw_dir.next() {
const DOT: &CStr = CStr::from_bytes_with_nul(b".\0").ok().unwrap();
const DOT_DOT: &CStr = CStr::from_bytes_with_nul(b"..\0").ok().unwrap();

let file = file.map_io_err(|| format!("Failed to read directory: {from:?}"))?;
if file.file_name() == DOT || file.file_name() == DOT_DOT {
continue;
}
if file.ino() == root_to_inode {
// Block recursive descent from parent into child (e.g. cp parent parent/child).
continue;
}
{
// TODO here and other uses: https://github.com/rust-lang/rust/issues/105723
let name = file.file_name().to_bytes();
if name == b"." || name == b".." {
continue;
}
}

let file_type = match file.file_type() {
FileType::Unknown => get_file_type(&from_dir, file.file_name(), from)?,
Expand Down Expand Up @@ -277,7 +278,8 @@ mod compat {
from_dir: impl AsFd,
TreeNode { from, to, .. }: &TreeNode,
) -> Result<OwnedFd, Error> {
const EMPTY: &CStr = CStr::from_bytes_with_nul(b"\0").ok().unwrap();
// TODO here and other uses: https://github.com/rust-lang/rust/issues/105723
const EMPTY: &CStr = unsafe { CStr::from_bytes_with_nul_unchecked(b"\0") };

let from_mode = {
let from_metadata = statx(from_dir, EMPTY, AtFlags::EMPTY_PATH, StatxFlags::MODE)
Expand Down Expand Up @@ -451,7 +453,8 @@ mod compat {
Ok(if let Some(ino) = *root_to_inode {
ino
} else {
const EMPTY: &CStr = CStr::from_bytes_with_nul(b"\0").ok().unwrap();
// TODO here and other uses: https://github.com/rust-lang/rust/issues/105723
const EMPTY: &CStr = unsafe { CStr::from_bytes_with_nul_unchecked(b"\0") };

let to_metadata = statx(to_dir, EMPTY, AtFlags::EMPTY_PATH, StatxFlags::INO)
.map_io_err(|| format!("Failed to stat directory: {to:?}"))?;
Expand Down
22 changes: 8 additions & 14 deletions fuc_engine/src/ops/remove.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,14 +83,8 @@ fn schedule_deletions<'a>(
#[cfg(target_os = "linux")]
mod compat {
use std::{
borrow::Cow,
ffi::{CStr, CString},
mem::MaybeUninit,
num::NonZeroUsize,
path::Path,
sync::Arc,
thread,
thread::JoinHandle,
borrow::Cow, ffi::CString, mem::MaybeUninit, num::NonZeroUsize, path::Path, sync::Arc,
thread, thread::JoinHandle,
};

use crossbeam_channel::{Receiver, Sender};
Expand Down Expand Up @@ -215,13 +209,13 @@ mod compat {
let node = LazyCell::new(|| Arc::new(node));
let mut raw_dir = RawDir::new(&dir, buf);
while let Some(file) = raw_dir.next() {
// TODO here and other uses: https://github.com/rust-lang/rust/issues/105723
const DOT: &CStr = CStr::from_bytes_with_nul(b".\0").ok().unwrap();
const DOT_DOT: &CStr = CStr::from_bytes_with_nul(b"..\0").ok().unwrap();

let file = file.map_io_err(|| format!("Failed to read directory: {:?}", node.path))?;
if file.file_name() == DOT || file.file_name() == DOT_DOT {
continue;
{
// TODO here and other uses: https://github.com/rust-lang/rust/issues/105723
let name = file.file_name().to_bytes();
if name == b"." || name == b".." {
continue;
}
}

let file_type = match file.file_type() {
Expand Down

0 comments on commit bbbfe20

Please sign in to comment.