Skip to content

Commit

Permalink
fix(windows): rustc false dead code positives
Browse files Browse the repository at this point in the history
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] rust-lang/rust@e69f14b
Refs: [2] DBCDK/faythe#101
Refs: rust-lang/rust#88900
Refs: #1342

Signed-off-by: Christina Sørensen <ces@fem.gg>
  • Loading branch information
cafkafk committed Jan 23, 2025
1 parent c9e247b commit d6ee81b
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 1 deletion.
7 changes: 7 additions & 0 deletions src/fs/fields.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand All @@ -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);

Expand All @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion src/output/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions src/output/render/links.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ impl f::Links {
}
}

#[allow(unused)]
pub trait Colours {
fn normal(&self) -> Style;
fn multi_link_file(&self) -> Style;
Expand Down
1 change: 1 addition & 0 deletions src/output/render/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
1 change: 1 addition & 0 deletions src/output/render/octal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
1 change: 1 addition & 0 deletions src/output/render/permissions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ impl PermissionsPlusRender for Option<f::PermissionsPlus> {
}
}

#[allow(unused)]
pub trait RenderPermissions {
fn render<C: Colours>(&self, colours: &C, is_regular_file: bool) -> Vec<ANSIString<'static>>;
}
Expand Down
1 change: 1 addition & 0 deletions src/theme/ui_styles.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Style>, // lc
Expand Down

0 comments on commit d6ee81b

Please sign in to comment.