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 cac2b4d commit 63e4bd2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
6 changes: 6 additions & 0 deletions detcore/src/scheduler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,15 @@ pub type Seconds = u32;
#[derive(Debug, Clone)]
pub struct Action {
/// Id for the action
#[allow(dead_code)]
pub action_id: ActionID,

/// The action's side effects are completed.
#[allow(dead_code)]
pub completion: Ivar<()>,

/// Which action gets the lock after me.
#[allow(dead_code)]
pub successors: HashMap<ResourceID, ActionID>,
}

Expand Down Expand Up @@ -232,6 +235,7 @@ pub struct Scheduler {
pub next_turns: BTreeMap<DetTid, ThreadNextTurn>,

/// The current set of actions in the background.
#[allow(dead_code)]
pub bg_action_pool: HashMap<ActionID, Action>,

/// The logical, global time consumed by actions that have been committed already.
Expand All @@ -242,6 +246,7 @@ pub struct Scheduler {

/// Ac table of "locks held": which action is using which resources.
/// A given resource can be held by at most one action at a given time.
#[allow(dead_code)]
pub resources: HashMap<ResourceID, ActionID>,

/// Initially false, set to true when the first thread is running.
Expand Down Expand Up @@ -726,6 +731,7 @@ pub struct ConsumeResult {
/// Should we print the stacktrace in the guest, as per --stacktrace-event
pub print_stack: MaybePrintStack,
/// The number of this event in the global total order of events.
#[allow(dead_code)]
pub event_ix: u64,
}

Expand Down
1 change: 1 addition & 0 deletions hermit-verify/src/common/env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ impl EnvPath {
#[derive(Clone)]
pub struct RunEnvironment {
// Root directory for one run
#[allow(dead_code)]
pub temp_dir: PathBuf,

// Path to log file
Expand Down

0 comments on commit 63e4bd2

Please sign in to comment.