Skip to content

Commit

Permalink
Resolve dead_code and unused_variables warnings
Browse files Browse the repository at this point in the history
Summary:
Rust 1.79's dead code scanner is more precise than previous versions. `pub` is no longer sufficient to hide a data structure field from the lint. It actually looks at whether an unused pub field is reachable from outside the crate.

In the following example, the field `field` is considered dead code by Rust 1.79 and not by 1.78.

```lang=rust
mod module {
    pub struct Struct {
        pub field: i32,
    }

    impl Struct {
        pub fn new() -> Self {
            Struct { field: 0 }
        }
    }
}

pub fn repro() {
    let _ = Struct::new();
}
```

Reviewed By: zertosh, JakobDegen

Differential Revision: D59623034

fbshipit-source-id: 6a4e2fb6e5be410d5127b451704df74ecdd42bf0
  • Loading branch information
David Tolnay authored and facebook-github-bot committed Jul 11, 2024
1 parent 4ca0347 commit b83fe4f
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/oomd/cfgen/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ pub struct FBTax2Attributes {
}

pub struct Oomd2Attributes {
#[allow(dead_code)]
pub blacklisted_jobs: Vec<&'static str>,
pub disable_swap_protection: bool,
pub kill_target: String,
Expand All @@ -57,6 +58,7 @@ pub struct Oomd2Attributes {
pub oomd_threshold_duration: String,
pub oomd_restart_threshold: BTreeMap<String, OomdRestartThreshold>,
pub oomd_reclaim_duation: String,
#[allow(dead_code)]
pub oomd_post_action_delay: String,
pub swap_protection_detect_threshold: String,
pub swap_protection_kill_threshold: String,
Expand Down

0 comments on commit b83fe4f

Please sign in to comment.