Skip to content

NLL diagnostics replaced nice closure errors w/ indecipherable free region errors #51027

Closed
@pnkfelix

Description

@pnkfelix

The following tests all have a common weakness around how they report errors under NLL. Under AST borrowck they would say something somewhat understandable about closures. But under NLL they don't anymore.

List:

  • borrowck/issue-45983.rs
  • borrowck/issue-7573.rs
  • borrowck/regions-escape-bound-fn-2.rs
  • borrowck/regions-escape-bound-fn.rs
  • borrowck/regions-escape-unboxed-closure.rs
  • closure-expected-type/expect-region-supply-region.rs
  • error-codes/E0621-does-not-trigger-for-closures.rs

(This list of tests is drawn from an informal paper document that I have been using to keep notes for myself as I work on this...)

Example (from ui/borrowck/issue-45983.rs):

AST borrowck says:

error: borrowed data cannot be stored outside of its closure
  --> $DIR/issue-45983.rs:17:27
   |
LL |     let x = None;
   |         - borrowed data cannot be stored into here...
LL |     give_any(|y| x = Some(y));
   |              ---          ^ cannot be stored outside of its closure
   |              |
| ...because it cannot outlive this closure

NLL says:

error: free region `` does not outlive free region `'_#2r`
  --> $DIR/issue-45983.rs:17:27
   |
LL |     give_any(|y| x = Some(y));
   |                           ^

Metadata

Metadata

Assignees

Labels

A-NLLArea: Non-lexical lifetimes (NLL)NLL-diagnosticsWorking towards the "diagnostic parity" goal

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions