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

NLL: unused_mut lint triggered by for _ in <unreachable> #54586

Closed
pnkfelix opened this issue Sep 26, 2018 · 3 comments
Closed

NLL: unused_mut lint triggered by for _ in <unreachable> #54586

pnkfelix opened this issue Sep 26, 2018 · 3 comments
Assignees
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-NLL Area: Non-lexical lifetimes (NLL) NLL-diagnostics Working towards the "diagnostic parity" goal

Comments

@pnkfelix
Copy link
Member

Consider the following code (play):

#![feature(nll)]
#![allow(unreachable_code)]

fn main() {
    for _ in { return (); 0..3 } {
    }
}

It signals the following diagnostic:

warning: variable does not need to be mutable
 --> src/main.rs:5:14
  |
5 |     for _ in { return (); 0..3 } {
  |              --^^^^^^^^^^^^^^^^^
  |              |
  |              help: remove this `mut`
  |
  = note: #[warn(unused_mut)] on by default

Which is pretty nonsensical in appearance.

(It almost certainly arises due to a legitimate mut appeared in the expansion of for. We probably just need to check whether a mut that has been introduced is due to legitimate source code or if its due to an internal expansion, and use that knowledge when we decide whether to signal the unused_mut lint.)

@csmoe csmoe added the A-diagnostics Area: Messages for errors, warnings, and lints label Sep 26, 2018
@pnkfelix pnkfelix added A-NLL Area: Non-lexical lifetimes (NLL) NLL-diagnostics Working towards the "diagnostic parity" goal labels Sep 26, 2018
@pnkfelix
Copy link
Member Author

putting on the RC2 milestone under the assumption that this should be relatively straight-forward to resolve.

@varkor
Copy link
Member

varkor commented Sep 26, 2018

This should be fixed in #54125, when it's merged.

@pnkfelix
Copy link
Member Author

pnkfelix commented Oct 2, 2018

I'm going to also assign @varkor since they have been participating in discussion about this. Even if @varkor makes the main PR, @blitzerr might be helpful in e.g. confirming the quality of the regression test, etc.

pietroalbini added a commit to pietroalbini/rust that referenced this issue Oct 5, 2018
…nikomatsakis

Only warn about unused `mut` in user-written code

Fixes rust-lang#54586.

r? @pnkfelix
cc @blitzerr
pietroalbini added a commit to pietroalbini/rust that referenced this issue Oct 23, 2018
…dness-check, r=nikomatsakis

Less conservative uninhabitedness check

Extends the uninhabitedness check to structs, non-empty enums, tuples and arrays.

Pulled out of rust-lang#47291 and rust-lang#50262.

Fixes rust-lang#54586.

r? @nikomatsakis
bors added a commit that referenced this issue Dec 20, 2018
…, r=nikomatsakis

Less conservative uninhabitedness check

Extends the uninhabitedness check to structs, non-empty enums, tuples and arrays.

Pulled out of #47291 and #50262.

Fixes #54586.

r? @nikomatsakis
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Jul 26, 2022
…r=Dylan-DPC

remove useless `#[allow]` in a test

The mentioned issue, rust-lang#54586 was fixed 4 years ago :)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-NLL Area: Non-lexical lifetimes (NLL) NLL-diagnostics Working towards the "diagnostic parity" goal
Projects
None yet
Development

No branches or pull requests

4 participants