Skip to content
New issue

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

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

Already on GitHub? # to your account

NLL migrate mode: issues two errors for single move out of borrow #55310

Closed
pnkfelix opened this issue Oct 24, 2018 · 5 comments
Closed

NLL migrate mode: issues two errors for single move out of borrow #55310

pnkfelix opened this issue Oct 24, 2018 · 5 comments
Labels
A-NLL Area: Non-lexical lifetimes (NLL) NLL-diagnostics Working towards the "diagnostic parity" goal T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@pnkfelix
Copy link
Member

This code (play):

struct S;
pub fn main() {
    let x = S;
    let _y = *&x;
}

issues the following diagnostics under migrate mode:

error[E0507]: cannot move out of borrowed content
 --> src/main.rs:4:14
  |
4 |     let _y = *&x;
  |              ^^^
  |              |
  |              cannot move out of borrowed content
  |              help: consider removing the `*`: `&x`

error[E0507]: cannot move out of data in a `&` reference
 --> src/main.rs:4:14
  |
4 |     let _y = *&x;
  |              ^^^
  |              |
  |              cannot move out of data in a `&` reference
  |              cannot move

error: aborting due to 2 previous errors

It issues only a single error under either of AST-borrowck or pure NLL.

@pnkfelix
Copy link
Member Author

(This is obviously one particular instance of #53004)

@pnkfelix
Copy link
Member Author

I think this test:

error[E0507]: cannot move out of borrowed content
--> $DIR/by-move-pattern-binding.rs:24:11
|
LL | match &s.x {
| ^^^^ cannot move out of borrowed content
LL | &E::Foo => {}
LL | &E::Bar(identifier) => f(identifier.clone()) //~ ERROR cannot move
| -------------------
| | |
| | data moved here
| help: consider removing the `&`: `E::Bar(identifier)`
|
note: move occurs because `identifier` has type `std::string::String`, which does not implement the `Copy` trait
--> $DIR/by-move-pattern-binding.rs:26:17
|
LL | &E::Bar(identifier) => f(identifier.clone()) //~ ERROR cannot move
| ^^^^^^^^^^
error[E0507]: cannot move out of data in a `&` reference
--> $DIR/by-move-pattern-binding.rs:26:17
|
LL | &E::Bar(identifier) => f(identifier.clone()) //~ ERROR cannot move
| ^^^^^^^^^^
| |
| cannot move out of data in a `&` reference
| cannot move
error: aborting due to 2 previous errors

is another instance of this. (But when/if we resolve this, one should double check that claim.)

@pnkfelix
Copy link
Member Author

This is probably fixed by PR #55221

@jonas-schievink jonas-schievink added A-NLL Area: Non-lexical lifetimes (NLL) NLL-diagnostics Working towards the "diagnostic parity" goal T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jan 27, 2019
@jonas-schievink
Copy link
Contributor

On current stable and nightly, the code only outputs one diagnostic now (migrate mode is on by default, right?).

@matthewjasper
Copy link
Contributor

Yes, this is fixed.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
A-NLL Area: Non-lexical lifetimes (NLL) NLL-diagnostics Working towards the "diagnostic parity" goal T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

3 participants