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

Too many errors for incorrect move in loop with NLL enabled #53807

Closed
estebank opened this issue Aug 29, 2018 · 0 comments
Closed

Too many errors for incorrect move in loop with NLL enabled #53807

estebank opened this issue Aug 29, 2018 · 0 comments
Assignees
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-NLL Area: Non Lexical Lifetimes (NLL) NLL-diagnostics Working torwads the "diagnostic parity" goal

Comments

@estebank
Copy link
Contributor

The following code with NLL enabled:

pub fn main(){
    let maybe = Some(vec![true, true]);
     loop {
        if let Some(thing) = maybe {
        }
    }
}

Has way too many errors being emitted:

error[E0382]: use of moved value: `maybe`
 --> src/main.rs:6:16
  |
6 |         if let Some(thing) = maybe {
  |                ^^^^^-----^
  |                |    |
  |                |    value moved here
  |                value used here after move
  |
  = note: move occurs because value has type `std::vec::Vec<bool>`, which does not implement the `Copy` trait

error[E0382]: use of moved value
 --> src/main.rs:6:21
  |
6 |         if let Some(thing) = maybe {
  |                     ^^^^^ value moved here in previous iteration of loop
  |
  = note: move occurs because value has type `std::vec::Vec<bool>`, which does not implement the `Copy` trait

error[E0382]: use of moved value: `maybe`
 --> src/main.rs:6:30
  |
6 |         if let Some(thing) = maybe {
  |                     -----    ^^^^^ value used here after move
  |                     |
  |                     value moved here
  |
  = note: move occurs because value has type `std::vec::Vec<bool>`, which does not implement the `Copy` trait

error[E0382]: borrow of moved value: `maybe`
 --> src/main.rs:6:30
  |
6 |         if let Some(thing) = maybe {
  |                     -----    ^^^^^ value borrowed here after move
  |                     |
  |                     value moved here
  |
  = note: move occurs because value has type `std::vec::Vec<bool>`, which does not implement the `Copy` trait

error: aborting due to 4 previous errors

Third and fourth are completely redundant, and all of them are talking about complaining about the same underlying problem. There should be only one error being emitted, ideally the second.

@estebank estebank added A-diagnostics Area: Messages for errors, warnings, and lints NLL-diagnostics Working torwads the "diagnostic parity" goal labels Aug 29, 2018
@pnkfelix pnkfelix added the A-NLL Area: Non Lexical Lifetimes (NLL) label Aug 30, 2018
@davidtwco davidtwco self-assigned this Sep 1, 2018
Mark-Simulacrum added a commit to Mark-Simulacrum/rust that referenced this issue Sep 8, 2018
Too many errors for incorrect move in loop with NLL enabled

Fixes rust-lang#53807.

r? @nikomatsakis
bors added a commit that referenced this issue Sep 19, 2018
NLL: Deduplicate errors for incorrect move in loop

Fixes #53807.

r? @nikomatsakis
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 torwads the "diagnostic parity" goal
Projects
None yet
Development

No branches or pull requests

3 participants