normalize after substitution

This commit is contained in:
Niko Matsakis 2018-10-17 12:31:44 -04:00
parent f99300fcbd
commit 121f3c8d19
3 changed files with 35 additions and 0 deletions

View file

@ -1008,6 +1008,7 @@ impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> {
let ty = self.tcx().type_of(def_id);
let ty = ty.subst(tcx, substs);
let ty = self.normalize(ty, locations);
self.relate_types(ty, v1, a, locations, category)?;

View file

@ -0,0 +1,24 @@
#![feature(nll)]
trait Mirror {
type Me;
}
impl<T> Mirror for T {
type Me = T;
}
trait Foo<'a> {
const C: <&'a u32 as Mirror>::Me;
}
impl<'a, T> Foo<'a> for T {
const C: &'a u32 = &22;
}
fn foo<'a>(_: &'a u32) -> &'static u32 {
<() as Foo<'a>>::C //~ ERROR
}
fn main() {
}

View file

@ -0,0 +1,10 @@
error: unsatisfied lifetime constraints
--> $DIR/constant-in-expr-normalize.rs:20:5
|
LL | fn foo<'a>(_: &'a u32) -> &'static u32 {
| -- lifetime `'a` defined here
LL | <() as Foo<'a>>::C //~ ERROR
| ^^^^^^^^^^^^^^^^^^ returning this value requires that `'a` must outlive `'static`
error: aborting due to previous error