diff --git a/src/test/ui/nll/user-annotations/normalization.rs b/src/test/ui/nll/user-annotations/normalization.rs new file mode 100644 index 000000000000..51d9adccd737 --- /dev/null +++ b/src/test/ui/nll/user-annotations/normalization.rs @@ -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 +} diff --git a/src/test/ui/nll/user-annotations/normalization.stderr b/src/test/ui/nll/user-annotations/normalization.stderr new file mode 100644 index 000000000000..489f9feb044c --- /dev/null +++ b/src/test/ui/nll/user-annotations/normalization.stderr @@ -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`.