Skip to content

Commit

Permalink
normalize the self-type that we extract from impl
Browse files Browse the repository at this point in the history
  • Loading branch information
nikomatsakis committed Oct 19, 2018
1 parent f5cc7db commit 9a7bb0e
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/librustc_mir/borrow_check/nll/type_check/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
25 changes: 25 additions & 0 deletions src/test/ui/nll/user-annotations/normalize-self-ty.rs
Original file line number Diff line number Diff line change
@@ -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);
}

0 comments on commit 9a7bb0e

Please sign in to comment.