diff --git a/src/uu/ln/Cargo.toml b/src/uu/ln/Cargo.toml index 8c53186517e..143ee287f94 100644 --- a/src/uu/ln/Cargo.toml +++ b/src/uu/ln/Cargo.toml @@ -18,13 +18,11 @@ doctest = false [dependencies] clap = { workspace = true } +rustix = { workspace = true, features = ["fs"] } uucore = { workspace = true, features = ["backup-control", "fs"] } thiserror = { workspace = true } fluent = { workspace = true } -[target.'cfg(target_os = "wasi")'.dependencies] -rustix = { workspace = true, features = ["fs"] } - [lints] workspace = true diff --git a/src/uu/ln/src/ln.rs b/src/uu/ln/src/ln.rs index 6391e78fe8c..3b24688b875 100644 --- a/src/uu/ln/src/ln.rs +++ b/src/uu/ln/src/ln.rs @@ -20,10 +20,6 @@ use std::ffi::OsString; use std::fs; use thiserror::Error; -#[cfg(any(unix, target_os = "redox"))] -use std::os::unix::fs::symlink; -#[cfg(windows)] -use std::os::windows::fs::{symlink_dir, symlink_file}; use std::path::{Path, PathBuf}; use uucore::backup_control::{self, BackupMode}; use uucore::fs::{MissingHandling, ResolveMode, canonicalize}; @@ -515,6 +511,7 @@ fn link(src: &Path, dst: &Path, settings: &Settings) -> LnResult<()> { #[cfg(windows)] pub fn symlink, P2: AsRef>(src: P1, dst: P2) -> io::Result<()> { + use std::os::windows::fs::{symlink_dir, symlink_file}; if src.as_ref().is_dir() { symlink_dir(src, dst) } else { @@ -522,7 +519,7 @@ pub fn symlink, P2: AsRef>(src: P1, dst: P2) -> io::Result } } -#[cfg(target_os = "wasi")] +#[cfg(any(unix, target_os = "wasi"))] pub fn symlink, P2: AsRef>(src: P1, dst: P2) -> io::Result<()> { rustix::fs::symlink(src.as_ref(), dst.as_ref()).map_err(io::Error::from) }