Skip to content

NLL migration mode sometimes prints more diagnostics than either AST-borrowck or NLL #53004

Closed
@pnkfelix

Description

@pnkfelix

While investigating #52979, I noticed some of the diagnostics from --edition 2018 are different than what either of the test.stderr and test.nll.stderr would lead one to expect to see.

This appears to arise from the implementation of -Z borrowck=migrate, from what I can tell.

For example, on ui/borrowck/borrowck-in-static.rs, we have from AST-borrowck:

error[E0507]: cannot move out of captured outer variable in an `Fn` closure
--> $DIR/borrowck-in-static.rs:15:17
|
LL | let x = Box::new(0);
| - captured outer variable
LL | Box::new(|| x) //~ ERROR cannot move out of captured outer variable
| ^ cannot move out of captured outer variable in an `Fn` closure
error: aborting due to previous error

and from NLL we have:

error[E0507]: cannot move out of captured variable in an `Fn` closure
--> $DIR/borrowck-in-static.rs:15:17
|
LL | Box::new(|| x) //~ ERROR cannot move out of captured outer variable
| ^ cannot move out of captured variable in an `Fn` closure
error: aborting due to previous error

but I am seeing this from -Z borrowck=migrate:

error[E0507]: cannot move out of captured variable in an `Fn` closure
  --> ../src/test/ui/borrowck/borrowck-in-static.rs:15:17
   |
15 |     Box::new(|| x) //~ ERROR cannot move out of captured outer variable
   |                 ^ cannot move out of captured variable in an `Fn` closure

error[E0507]: cannot move out of `x`, as it is a captured variable in a `Fn` closure
  --> ../src/test/ui/borrowck/borrowck-in-static.rs:15:17
   |
15 |     Box::new(|| x) //~ ERROR cannot move out of captured outer variable
   |                 ^
   |                 |
   |                 cannot move out of `x`, as it is a captured variable in a `Fn` closure
   |                 cannot move
   |
help: consider changing this to accept closures that implement `FnMut`
  --> ../src/test/ui/borrowck/borrowck-in-static.rs:15:14
   |
15 |     Box::new(|| x) //~ ERROR cannot move out of captured outer variable
   |              ^^^^

error: aborting due to 2 previous errors

My guess that this is arising because I must have missed at least one case where AST-borrowck signals an error. Thus, when the -Z borrowck=migrate runs the AST-borrowck as a fallback in response to an error encounters during the MIR-borrowck, the user can sometimes see the both sets the errors from both NLL and AST-borrowck.

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.metabugIssues about issues themselves ("bugs about bugs")

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions