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

NLL diagnostics fail to report lifetime mismatches #51029

Closed
1 task
pnkfelix opened this issue May 24, 2018 · 2 comments
Closed
1 task

NLL diagnostics fail to report lifetime mismatches #51029

pnkfelix opened this issue May 24, 2018 · 2 comments
Labels
A-NLL Area: Non-lexical lifetimes (NLL)

Comments

@pnkfelix
Copy link
Member

pnkfelix commented May 24, 2018

The following tests report the lifetime mismatches nicely under AST borrowck but fail to do so under NLL.

Tests:

  • lifetime-errors/ex3-both-anon-regions-2.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 (ex3-both-anon-regions-2.rs)

AST diagnostic:

error[E0623]: lifetime mismatch
  --> $DIR/ex3-both-anon-regions-2.rs:12:9
   |
LL | fn foo((v, w): (&u8, &u8), x: &u8) {
   |                 ---           --- these two types are declared with different lifetimes...
LL |     v = x; //~ ERROR lifetime mismatch
   |         ^ ...but data from `x` flows here

NLL diagnostic:

warning: not reporting region error due to nll
  --> $DIR/ex3-both-anon-regions-2.rs:12:9
   |
LL |     v = x; //~ ERROR lifetime mismatch
| ^

Update (pnkfelix)

  • Wait, is this assignment actually legal under NLL? Seems like it shouldn't be legal. But the test could be made more robust to actually illustrate why such an assignment would be broken.
@pnkfelix
Copy link
Member Author

I don't think the assignment as written should be broken under NLL. its not like we're mutating the tuple in the way that the caller can observe.

If this were a &mut (ref mut v, w): &mut (&u8, &u8), x: &u8, then we might be going somewhere, right?

@pnkfelix
Copy link
Member Author

I ended up adopting the aforementioned form of the test in #51057

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-NLL Area: Non-lexical lifetimes (NLL)
Projects
None yet
Development

No branches or pull requests

1 participant