Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix false negative for unused_mut #110960

Merged
merged 2 commits into from
Apr 29, 2023
Merged

fix false negative for unused_mut #110960

merged 2 commits into from
Apr 29, 2023

Conversation

lukas-code
Copy link
Member

fixes #110849

We want to avoid double diagnostics for code like this, but only if an error actually occurs:

fn main() {
    let mut x: (i32, i32);
    x.0 = 1;
}

The first commit fixes the lint and the second one removes all the unused muts it found.

@rustbot
Copy link
Collaborator

rustbot commented Apr 28, 2023

r? @compiler-errors

(rustbot has picked a reviewer for you, use r? to override)

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Apr 28, 2023
Copy link
Member

@compiler-errors compiler-errors left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense, just moving the used_mut only onto the path where the error reporting is actually happening.

@compiler-errors
Copy link
Member

@bors r+

@bors
Copy link
Contributor

bors commented Apr 28, 2023

📌 Commit fc63926 has been approved by compiler-errors

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Apr 28, 2023
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Apr 28, 2023
…errors

fix false negative for `unused_mut`

fixes rust-lang#110849

We want to avoid double diagnostics for code like this, but only if an error actually occurs:
```rust
fn main() {
    let mut x: (i32, i32);
    x.0 = 1;
}
```

The first commit fixes the lint and the second one removes all the unused `mut`s it found.
bors added a commit to rust-lang-ci/rust that referenced this pull request Apr 28, 2023
…iaskrgr

Rollup of 8 pull requests

Successful merges:

 - rust-lang#110877 (Provide better type hints when a type doesn't support a binary operator)
 - rust-lang#110917 (only error combining +whole-archive and +bundle for rlibs)
 - rust-lang#110921 (Use `NonNull::new_unchecked` and `NonNull::len` in `rustc_arena`.)
 - rust-lang#110927 (Encoder/decoder cleanups)
 - rust-lang#110944 (share BinOp::Offset between CTFE and Miri)
 - rust-lang#110948 (run-make test: using single quotes to not trigger the shell)
 - rust-lang#110957 (Fix an ICE in conflict error diagnostics)
 - rust-lang#110960 (fix false negative for `unused_mut`)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 34ef13b into rust-lang:master Apr 29, 2023
@rustbot rustbot added this to the 1.71.0 milestone Apr 29, 2023
@lukas-code lukas-code deleted the unused-mut branch April 29, 2023 08:36
bors added a commit to rust-lang/cargo that referenced this pull request May 1, 2023
Fix warning with unused mut

### What does this PR try to resolve?

```
warning: variable does not need to be mutable
   --> src/cargo/core/compiler/unit_dependencies.rs:152:5
    |
152 |     mut state: &mut State<'_, '_>,
    |     ----^^^^^
    |     |
    |     help: remove this `mut`
    |
    = note: `#[warn(unused_mut)]` on by default

warning: `cargo` (lib) generated 1 warning (run `cargo fix --lib -p cargo` to apply 1 suggestion)
```

This is caused by rust-lang/rust#110960

### How should we test and review this PR?

Running the mainline rust toolchain and `cargo build` without any wanrning messages would look like the above.

### Additional information

None
charles-r-earp pushed a commit to charles-r-earp/cargo that referenced this pull request May 3, 2023
ehuss added a commit to ehuss/git2-rs that referenced this pull request May 5, 2023
A false negative for unused_mut was fixed in rust-lang/rust#110960.
weihanglo pushed a commit to weihanglo/cargo that referenced this pull request May 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

False negative for unused_mut when writing to field through reference
4 participants