Skip to content

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

Closed
@pnkfelix

Description

@pnkfelix

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-NLLArea: Non-lexical lifetimes (NLL)NLL-diagnosticsWorking towards the "diagnostic parity" goalT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions