Преглед изворни кода

fix(windows): rustc false dead code positives

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 <ces@fem.gg>
Christina Sørensen пре 1 година
родитељ
комит
7a7393d2ac

+ 7 - 0
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);
 

+ 1 - 1
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;

+ 1 - 0
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;

+ 1 - 0
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
 

+ 1 - 0
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;
 }

+ 1 - 0
src/output/render/permissions.rs

@@ -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>>;
 }

+ 1 - 0
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<Style>,           // lc