@@ -79,13 +79,8 @@ pub trait AstConv<'gcx, 'tcx> {
7979 item_name : ast:: Name )
8080 -> Ty < ' tcx > ;
8181
82- /// Project an associated type from a non-higher-ranked trait reference.
83- /// This is fairly straightforward and can be accommodated in any context.
84- fn projected_ty ( & self ,
85- span : Span ,
86- _trait_ref : ty:: TraitRef < ' tcx > ,
87- _item_name : ast:: Name )
88- -> Ty < ' tcx > ;
82+ /// Normalize an associated type coming from the user.
83+ fn normalize_ty ( & self , span : Span , ty : Ty < ' tcx > ) -> Ty < ' tcx > ;
8984
9085 /// Invoked when we encounter an error from some prior pass
9186 /// (e.g. resolve) that is translated into a ty-error. This is
@@ -310,8 +305,11 @@ impl<'o, 'gcx: 'tcx, 'tcx> AstConv<'gcx, 'tcx>+'o {
310305 tcx. types . err
311306 } else {
312307 // This is a default type parameter.
313- ty:: queries:: ty:: get ( tcx, span, def. def_id )
314- . subst_spanned ( tcx, substs, Some ( span) )
308+ self . normalize_ty (
309+ span,
310+ ty:: queries:: ty:: get ( tcx, span, def. def_id )
311+ . subst_spanned ( tcx, substs, Some ( span) )
312+ )
315313 }
316314 } else {
317315 // We've already errored above about the mismatch.
@@ -600,7 +598,10 @@ impl<'o, 'gcx: 'tcx, 'tcx> AstConv<'gcx, 'tcx>+'o {
600598 -> Ty < ' tcx >
601599 {
602600 let substs = self . ast_path_substs_for_ty ( span, did, item_segment) ;
603- ty:: queries:: ty:: get ( self . tcx ( ) , span, did) . subst ( self . tcx ( ) , substs)
601+ self . normalize_ty (
602+ span,
603+ ty:: queries:: ty:: get ( self . tcx ( ) , span, did) . subst ( self . tcx ( ) , substs)
604+ )
604605 }
605606
606607 /// Transform a PolyTraitRef into a PolyExistentialTraitRef by
@@ -900,6 +901,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> AstConv<'gcx, 'tcx>+'o {
900901
901902 let trait_did = bound. 0 . def_id ;
902903 let ty = self . projected_ty_from_poly_trait_ref ( span, bound, assoc_name) ;
904+ let ty = self . normalize_ty ( span, ty) ;
903905
904906 let item = tcx. associated_items ( trait_did) . find ( |i| i. name == assoc_name) ;
905907 let def_id = item. expect ( "missing associated type" ) . def_id ;
@@ -939,7 +941,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> AstConv<'gcx, 'tcx>+'o {
939941
940942 debug ! ( "qpath_to_ty: trait_ref={:?}" , trait_ref) ;
941943
942- self . projected_ty ( span, trait_ref, item_segment. name )
944+ self . normalize_ty ( span, tcx . mk_projection ( trait_ref, item_segment. name ) )
943945 }
944946
945947 pub fn prohibit_type_params ( & self , segments : & [ hir:: PathSegment ] ) {
0 commit comments