From d6ee81b6f911d21023750e2cb9f6d7eff44bf379 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christina=20S=C3=B8rensen?= Date: Thu, 23 Jan 2025 15:57:30 +0100 Subject: [PATCH] fix(windows): rustc false dead code positives MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Apparently, upstream rust decided to change the behavior of dead/unused code detection in a way that causes a lot of false positives. For some (yet known) reason, this only hit on the windows build, but I've confirmed that these are indeed false positives, and removing this "dead code" breaks the build. Frustratingly, we only hit this to fix *another issue*[1] with upstream rust... And this litters our code with directives where we "allow unused" that isn't unused. I coindicentally also saw this at dayjob today[2], and yes, this is real, so we'll just have to do it. Refs: [1] https://github.com/rust-lang/rust/commit/e69f14b14cfa6e2ae863adb07e9add736d1f45fc Refs: [2] https://github.com/DBCDK/faythe/pull/101 Refs: https://github.com/rust-lang/rust/issues/88900 Refs: #1342 Signed-off-by: Christina Sørensen --- src/fs/fields.rs | 7 +++++++ src/output/mod.rs | 2 +- src/output/render/links.rs | 1 + src/output/render/mod.rs | 1 + src/output/render/octal.rs | 1 + src/output/render/permissions.rs | 1 + src/theme/ui_styles.rs | 1 + 7 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/fs/fields.rs b/src/fs/fields.rs index 961f9eff2..6f8c4efa6 100644 --- a/src/fs/fields.rs +++ b/src/fs/fields.rs @@ -24,15 +24,18 @@ pub type gid_t = u32; /// The type of a file’s inode. +#[allow(unused)] pub type ino_t = u64; /// The type of a file’s number of links. +#[allow(unused)] pub type nlink_t = u64; /// The type of a file’s timestamp (creation, modification, access, etc). pub type time_t = i64; /// The type of a file’s user ID. +#[allow(unused)] pub type uid_t = u32; /// The type of user file flags @@ -123,6 +126,7 @@ pub struct OctalPermissions { /// multiple directories. However, it’s rare (but occasionally useful!) for a /// regular file to have a link count greater than 1, so we highlight the /// block count specifically for this case. +#[allow(unused)] #[derive(Copy, Clone)] pub struct Links { /// The actual link count. @@ -135,6 +139,7 @@ pub struct Links { /// A file’s inode. Every directory entry on a Unix filesystem has an inode, /// including directories and links, so this is applicable to everything exa /// can deal with. +#[allow(unused)] #[derive(Copy, Clone)] pub struct Inode(pub ino_t); @@ -151,10 +156,12 @@ pub enum Blocksize { /// The ID of the user that owns a file. This will only ever be a number; /// looking up the username is done in the `display` module. +#[allow(unused)] #[derive(Copy, Clone)] pub struct User(pub uid_t); /// The ID of the group that a file belongs to. +#[allow(unused)] #[derive(Copy, Clone)] pub struct Group(pub gid_t); diff --git a/src/output/mod.rs b/src/output/mod.rs index c36972af5..33691279b 100644 --- a/src/output/mod.rs +++ b/src/output/mod.rs @@ -5,7 +5,7 @@ // SPDX-FileCopyrightText: 2014 Benjamin Sago // SPDX-License-Identifier: MIT #[cfg(target_os = "windows")] -pub use self::cell::{DisplayWidth, TextCell, TextCellContents}; +pub use self::cell::TextCell; pub use self::escape::escape; pub mod color_scale; diff --git a/src/output/render/links.rs b/src/output/render/links.rs index d44db4225..e69cff53e 100644 --- a/src/output/render/links.rs +++ b/src/output/render/links.rs @@ -26,6 +26,7 @@ impl f::Links { } } +#[allow(unused)] pub trait Colours { fn normal(&self) -> Style; fn multi_link_file(&self) -> Style; diff --git a/src/output/render/mod.rs b/src/output/render/mod.rs index e81d6d149..23ff77378 100644 --- a/src/output/render/mod.rs +++ b/src/output/render/mod.rs @@ -46,6 +46,7 @@ pub use self::users::Colours as UserColours; pub use self::users::Render as UserRender; mod octal; +#[cfg(unix)] pub use self::octal::Render as OctalPermissionsRender; // octal uses just one colour diff --git a/src/output/render/octal.rs b/src/output/render/octal.rs index 155b3f691..385594124 100644 --- a/src/output/render/octal.rs +++ b/src/output/render/octal.rs @@ -9,6 +9,7 @@ use nu_ansi_term::Style; use crate::fs::fields as f; use crate::output::cell::TextCell; +#[allow(unused)] pub trait Render { fn render(&self, style: Style) -> TextCell; } diff --git a/src/output/render/permissions.rs b/src/output/render/permissions.rs index 71edd574e..2c88ca5b8 100644 --- a/src/output/render/permissions.rs +++ b/src/output/render/permissions.rs @@ -67,6 +67,7 @@ impl PermissionsPlusRender for Option { } } +#[allow(unused)] pub trait RenderPermissions { fn render(&self, colours: &C, is_regular_file: bool) -> Vec>; } diff --git a/src/theme/ui_styles.rs b/src/theme/ui_styles.rs index c151260c7..5f2b047a9 100644 --- a/src/theme/ui_styles.rs +++ b/src/theme/ui_styles.rs @@ -250,6 +250,7 @@ field_accessors!( ); #[rustfmt::skip] +#[allow(unused)] #[derive(Clone, Copy, Debug, Eq, Default, PartialEq, Serialize, Deserialize)] pub struct Links { pub normal: Option