add a test that we enforce 'static errors post normalization

This commit is contained in:
Niko Matsakis 2018-10-18 14:26:33 -04:00
parent 820c2657f2
commit 16b3ea1e2e
2 changed files with 26 additions and 0 deletions

View file

@ -0,0 +1,13 @@
// Test that we enforce a `&'static` requirement that is only visible
// after normalization.
#![feature(nll)]
#![ignore(unused)]
trait Foo { type Out; }
impl Foo for () { type Out = &'static u32; }
fn main() {
let a = 22;
let b: <() as Foo>::Out = &a; //~ ERROR
}

View file

@ -0,0 +1,13 @@
error[E0597]: `a` does not live long enough
--> $DIR/normalization.rs:12:31
|
LL | let b: <() as Foo>::Out = &a; //~ ERROR
| ^^ borrowed value does not live long enough
LL | }
| - `a` dropped here while still borrowed
|
= note: borrowed value must be valid for the static lifetime...
error: aborting due to previous error
For more information about this error, try `rustc --explain E0597`.