Skip to content

Fix warnings for rust 1.87 and upgrade CI rust version#3591

Merged
stevenengler merged 5 commits intoshadow:mainfrom
stevenengler:fix-warnings
May 19, 2025
Merged

Fix warnings for rust 1.87 and upgrade CI rust version#3591
stevenengler merged 5 commits intoshadow:mainfrom
stevenengler:fix-warnings

Conversation

@stevenengler
Copy link
Copy Markdown
Contributor

@stevenengler stevenengler commented May 17, 2025

Fixes clippy warnings in rust 1.87, and upgrades the rust version in CI.

When running clippy with rust 1.88-beta, we get "'shadow-rs' (lib test) generated 152 warnings", so we have that to look forward to in 6 weeks :)

@stevenengler stevenengler self-assigned this May 17, 2025
@github-actions github-actions bot added Component: Libraries Support functions like LD_PRELOAD and logging Component: Testing Unit and integration tests and frameworks Component: Main Composing the core Shadow executable labels May 17, 2025
Also changed a `vals.iter().all(|val| *val != compare)` to
`!vals.contains(&compare)` for consistency, even though it wasn't part
of the warning.

```text
warning: using `contains()` instead of `iter().any()` is more efficient
  --> test/socket/socket/test_socket.rs:15:33
   |
15 |             Cond::Only(vals) => vals.iter().any(|val| *val == compare),
   |                                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `vals.contains(&compare)`
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#manual_contains
   = note: `#[warn(clippy::manual_contains)]` on by default
```
```text
warning: replacing a value of type `T` with `T::default()` is better expressed using `std::mem::take`
  --> main/core/sim_stats.rs:95:31
   |
95 |                   alloc_counts: std::mem::replace(
   |  _______________________________^
96 | |                     &mut stats.alloc_counts.lock().unwrap(),
97 | |                     Counter::new(),
98 | |                 ),
   | |_________________^ help: consider using: `std::mem::take(&mut stats.alloc_counts.lock().unwrap())`
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#mem_replace_with_default
   = note: `#[warn(clippy::mem_replace_with_default)]` on by default
```
```text
warning: large size difference between variants
   --> main/host/process.rs:815:1
    |
815 | / enum ProcessState {
816 | |     Runnable(RunnableProcess),
    | |     ------------------------- the largest variant contains at least 360 bytes
817 | |     Zombie(ZombieProcess),
    | |     --------------------- the second-largest variant contains at least 88 bytes
818 | | }
    | |_^ the entire enum is at least 360 bytes
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#large_enum_variant
    = note: `#[warn(clippy::large_enum_variant)]` on by default
help: consider boxing the large fields to reduce the total size of the enum
    |
816 -     Runnable(RunnableProcess),
816 +     Runnable(Box<RunnableProcess>),
```
@github-actions github-actions bot added the Component: Documentation In-repository documentation, under docs/ label May 17, 2025
@stevenengler stevenengler requested a review from a team May 17, 2025 22:53
@stevenengler stevenengler merged commit bd6b1f7 into shadow:main May 19, 2025
26 checks passed
@stevenengler stevenengler deleted the fix-warnings branch May 19, 2025 04:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Component: Documentation In-repository documentation, under docs/ Component: Libraries Support functions like LD_PRELOAD and logging Component: Main Composing the core Shadow executable Component: Testing Unit and integration tests and frameworks

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants