Skip to content

Commit 7b92803

Browse files
committed
wasi: fix warnings
1 parent 424e74e commit 7b92803

File tree

4 files changed

+17
-9
lines changed

4 files changed

+17
-9
lines changed

src/uu/cp/src/cp.rs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1896,12 +1896,13 @@ pub(crate) fn copy_attributes(
18961896
fn symlink_file(
18971897
source: &Path,
18981898
dest: &Path,
1899-
symlinked_files: &mut HashSet<FileInformation>,
1899+
#[cfg(not(target_os = "wasi"))] symlinked_files: &mut HashSet<FileInformation>,
1900+
#[cfg(target_os = "wasi")] _symlinked_files: &mut HashSet<FileInformation>,
19001901
) -> CopyResult<()> {
19011902
#[cfg(target_os = "wasi")]
19021903
{
19031904
return Err(CpError::IoErrContext(
1904-
std::io::Error::new(std::io::ErrorKind::Unsupported, "symlinks not supported"),
1905+
io::Error::new(io::ErrorKind::Unsupported, "symlinks not supported"),
19051906
translate!("cp-error-cannot-create-symlink",
19061907
"dest" => get_filename(dest).unwrap_or("?").quote(),
19071908
"source" => get_filename(source).unwrap_or("?").quote()),
@@ -1930,10 +1931,13 @@ fn symlink_file(
19301931
)
19311932
})?;
19321933
}
1933-
if let Ok(file_info) = FileInformation::from_path(dest, false) {
1934-
symlinked_files.insert(file_info);
1934+
#[cfg(not(target_os = "wasi"))]
1935+
{
1936+
if let Ok(file_info) = FileInformation::from_path(dest, false) {
1937+
symlinked_files.insert(file_info);
1938+
}
1939+
Ok(())
19351940
}
1936-
Ok(())
19371941
}
19381942

19391943
fn context_for(src: &Path, dest: &Path) -> String {

src/uu/mv/src/mv.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -929,7 +929,7 @@ fn rename_symlink_fallback(from: &Path, to: &Path) -> io::Result<()> {
929929
}
930930

931931
#[cfg(target_os = "wasi")]
932-
fn rename_symlink_fallback(from: &Path, to: &Path) -> io::Result<()> {
932+
fn rename_symlink_fallback(_from: &Path, _to: &Path) -> io::Result<()> {
933933
Err(io::Error::new(
934934
io::ErrorKind::Other,
935935
translate!("mv-error-no-symlink-support"),

src/uu/wc/src/countable.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ pub trait WordCountable: AsFd + AsRawFd + Read {
2424
pub trait WordCountable: Read {
2525
type Buffered: BufRead;
2626
fn buffered(self) -> Self::Buffered;
27+
#[cfg(not(target_os = "wasi"))]
2728
fn inner_file(&mut self) -> Option<&mut File>;
2829
}
2930

@@ -33,6 +34,8 @@ impl WordCountable for StdinLock<'_> {
3334
fn buffered(self) -> Self::Buffered {
3435
self
3536
}
37+
38+
#[cfg(not(target_os = "wasi"))]
3639
fn inner_file(&mut self) -> Option<&mut File> {
3740
None
3841
}
@@ -45,6 +48,7 @@ impl WordCountable for File {
4548
BufReader::new(self)
4649
}
4750

51+
#[cfg(not(target_os = "wasi"))]
4852
fn inner_file(&mut self) -> Option<&mut File> {
4953
Some(self)
5054
}

src/uucore/src/lib/features/fs.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ pub struct FileInformation(
4646
#[cfg(unix)] nix::sys::stat::FileStat,
4747
#[cfg(windows)] winapi_util::file::Information,
4848
// WASI does not have nix::sys::stat, so we store std::fs::Metadata instead.
49-
#[cfg(target_os = "wasi")] std::fs::Metadata,
49+
#[cfg(target_os = "wasi")] fs::Metadata,
5050
);
5151

5252
impl FileInformation {
@@ -97,9 +97,9 @@ impl FileInformation {
9797
#[cfg(target_os = "wasi")]
9898
{
9999
let metadata = if dereference {
100-
std::fs::metadata(path.as_ref())
100+
fs::metadata(path.as_ref())
101101
} else {
102-
std::fs::symlink_metadata(path.as_ref())
102+
fs::symlink_metadata(path.as_ref())
103103
};
104104
Ok(Self(metadata?))
105105
}

0 commit comments

Comments
 (0)