Skip to content

Commit 121f3c8

Browse files
committed
normalize after substitution
1 parent f99300f commit 121f3c8

File tree

3 files changed

+35
-0
lines changed

3 files changed

+35
-0
lines changed

src/librustc_mir/borrow_check/nll/type_check/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1008,6 +1008,7 @@ impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> {
10081008

10091009
let ty = self.tcx().type_of(def_id);
10101010
let ty = ty.subst(tcx, substs);
1011+
let ty = self.normalize(ty, locations);
10111012

10121013
self.relate_types(ty, v1, a, locations, category)?;
10131014

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#![feature(nll)]
2+
3+
trait Mirror {
4+
type Me;
5+
}
6+
7+
impl<T> Mirror for T {
8+
type Me = T;
9+
}
10+
11+
trait Foo<'a> {
12+
const C: <&'a u32 as Mirror>::Me;
13+
}
14+
15+
impl<'a, T> Foo<'a> for T {
16+
const C: &'a u32 = &22;
17+
}
18+
19+
fn foo<'a>(_: &'a u32) -> &'static u32 {
20+
<() as Foo<'a>>::C //~ ERROR
21+
}
22+
23+
fn main() {
24+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
error: unsatisfied lifetime constraints
2+
--> $DIR/constant-in-expr-normalize.rs:20:5
3+
|
4+
LL | fn foo<'a>(_: &'a u32) -> &'static u32 {
5+
| -- lifetime `'a` defined here
6+
LL | <() as Foo<'a>>::C //~ ERROR
7+
| ^^^^^^^^^^^^^^^^^^ returning this value requires that `'a` must outlive `'static`
8+
9+
error: aborting due to previous error
10+

0 commit comments

Comments
 (0)