diff options
| author | Niko Matsakis <niko@alum.mit.edu> | 2018-10-18 15:48:48 -0400 |
|---|---|---|
| committer | Niko Matsakis <niko@alum.mit.edu> | 2018-10-19 09:34:28 -0400 |
| commit | 9a7bb0ef249258aacf144d04f5d437ba70533128 (patch) | |
| tree | 96657ab509a45e40af4d17261b53244a67d1293c /src | |
| parent | f5cc7dba8a32c1f83f3b3102f398405dc540841f (diff) | |
| download | rust-9a7bb0ef249258aacf144d04f5d437ba70533128.tar.gz rust-9a7bb0ef249258aacf144d04f5d437ba70533128.zip | |
normalize the self-type that we extract from impl
Diffstat (limited to 'src')
| -rw-r--r-- | src/librustc_mir/borrow_check/nll/type_check/mod.rs | 1 | ||||
| -rw-r--r-- | src/test/ui/nll/user-annotations/normalize-self-ty.rs | 25 |
2 files changed, 26 insertions, 0 deletions
diff --git a/src/librustc_mir/borrow_check/nll/type_check/mod.rs b/src/librustc_mir/borrow_check/nll/type_check/mod.rs index 6783083c958..7737fcc765d 100644 --- a/src/librustc_mir/borrow_check/nll/type_check/mod.rs +++ b/src/librustc_mir/borrow_check/nll/type_check/mod.rs @@ -1019,6 +1019,7 @@ impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> { { let impl_self_ty = tcx.type_of(impl_def_id); let impl_self_ty = impl_self_ty.subst(tcx, &substs); + let impl_self_ty = self.normalize(impl_self_ty, locations); // There may be type variables in `substs` and hence // in `impl_self_ty`, but they should all have been diff --git a/src/test/ui/nll/user-annotations/normalize-self-ty.rs b/src/test/ui/nll/user-annotations/normalize-self-ty.rs new file mode 100644 index 00000000000..d97cc88dd9a --- /dev/null +++ b/src/test/ui/nll/user-annotations/normalize-self-ty.rs @@ -0,0 +1,25 @@ +// Regression test for #55183: check a case where the self type from +// the inherent impl requires normalization to be equal to the +// user-provided type. +// +// run-pass + +#![feature(nll)] + +trait Mirror { + type Me; +} + +impl<T> Mirror for T { + type Me = T; +} + +struct Foo<A, B>(A, B); + +impl<A> Foo<A, <A as Mirror>::Me> { + fn m(b: A) { } +} + +fn main() { + <Foo<&'static u32, &u32>>::m(&22); +} |
