-
Notifications
You must be signed in to change notification settings - Fork 13k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Handle type annotations in promoted MIR correctly
Type annotations are shared between the MIR of a function and the promoted constants for that function, so keep them in the type checker when we check the promoted MIR.
- Loading branch information
1 parent
848c252
commit 3b93d71
Showing
3 changed files
with
46 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
// Test that type annotations are checked in promoted constants correctly. | ||
|
||
#![feature(nll)] | ||
|
||
fn foo<'a>() { | ||
let x = 0; | ||
let f = &drop::<&'a i32>; | ||
f(&x); | ||
//~^ ERROR `x` does not live long enough | ||
} | ||
|
||
fn main() {} |
17 changes: 17 additions & 0 deletions
17
src/test/ui/nll/user-annotations/promoted-annotation.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
error[E0597]: `x` does not live long enough | ||
--> $DIR/promoted-annotation.rs:8:7 | ||
| | ||
LL | fn foo<'a>() { | ||
| -- lifetime `'a` defined here | ||
LL | let x = 0; | ||
LL | let f = &drop::<&'a i32>; | ||
| ---------------- assignment requires that `x` is borrowed for `'a` | ||
LL | f(&x); | ||
| ^^ borrowed value does not live long enough | ||
LL | //~^ ERROR `x` does not live long enough | ||
LL | } | ||
| - `x` dropped here while still borrowed | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0597`. |