@@ -60,7 +60,7 @@ use middle::traits;
6060use middle:: ty:: { self , RegionEscape , Ty , ToPredicate , HasTypeFlags } ;
6161use middle:: ty_fold;
6262use require_c_abi_if_variadic;
63- use rscope:: { self , UnelidableRscope , RegionScope , ElidableRscope , ExplicitRscope ,
63+ use rscope:: { self , UnelidableRscope , RegionScope , ElidableRscope ,
6464 ObjectLifetimeDefaultRscope , ShiftedRscope , BindingRscope ,
6565 ElisionFailureInfo , ElidedLifetime } ;
6666use util:: common:: { ErrorReported , FN_OUTPUT_NAME } ;
@@ -1208,40 +1208,33 @@ fn associated_path_def_to_ty<'tcx>(this: &AstConv<'tcx>,
12081208 ( _, def:: DefSelfTy ( Some ( trait_did) , Some ( ( impl_id, _) ) ) ) => {
12091209 // `Self` in an impl of a trait - we have a concrete self type and a
12101210 // trait reference.
1211- match tcx. map . expect_item ( impl_id) . node {
1212- ast:: ItemImpl ( _, _, _, Some ( ref trait_ref) , _, _) => {
1213- if this. ensure_super_predicates ( span, trait_did) . is_err ( ) {
1214- return ( tcx. types . err , ty_path_def) ;
1215- }
1211+ let trait_ref = tcx. impl_trait_ref ( ast_util:: local_def ( impl_id) ) . unwrap ( ) ;
1212+ let trait_ref = if let Some ( free_substs) = this. get_free_substs ( ) {
1213+ trait_ref. subst ( tcx, free_substs)
1214+ } else {
1215+ trait_ref
1216+ } ;
12161217
1217- let trait_segment = & trait_ref. path . segments . last ( ) . unwrap ( ) ;
1218- let trait_ref = ast_path_to_mono_trait_ref ( this,
1219- & ExplicitRscope ,
1220- span,
1221- PathParamMode :: Explicit ,
1222- trait_did,
1223- Some ( ty) ,
1224- trait_segment) ;
1225-
1226- let candidates: Vec < ty:: PolyTraitRef > =
1227- traits:: supertraits ( tcx, ty:: Binder ( trait_ref. clone ( ) ) )
1228- . filter ( |r| this. trait_defines_associated_type_named ( r. def_id ( ) ,
1229- assoc_name) )
1230- . collect ( ) ;
1231-
1232- match one_bound_for_assoc_type ( tcx,
1233- candidates,
1234- "Self" ,
1235- & token:: get_name ( assoc_name) ,
1236- span) {
1237- Ok ( bound) => bound,
1238- Err ( ErrorReported ) => return ( tcx. types . err , ty_path_def) ,
1239- }
1240- }
1241- _ => unreachable ! ( )
1218+ if this. ensure_super_predicates ( span, trait_did) . is_err ( ) {
1219+ return ( tcx. types . err , ty_path_def) ;
1220+ }
1221+
1222+ let candidates: Vec < ty:: PolyTraitRef > =
1223+ traits:: supertraits ( tcx, ty:: Binder ( trait_ref) )
1224+ . filter ( |r| this. trait_defines_associated_type_named ( r. def_id ( ) ,
1225+ assoc_name) )
1226+ . collect ( ) ;
1227+
1228+ match one_bound_for_assoc_type ( tcx,
1229+ candidates,
1230+ "Self" ,
1231+ & token:: get_name ( assoc_name) ,
1232+ span) {
1233+ Ok ( bound) => bound,
1234+ Err ( ErrorReported ) => return ( tcx. types . err , ty_path_def) ,
12421235 }
12431236 }
1244- ( & ty:: TyParam ( _) , def:: DefSelfTy ( Some ( trait_did) , None ) ) => {
1237+ ( & ty:: TyParam ( _) , def:: DefSelfTy ( Some ( trait_did) , None ) ) => {
12451238 assert_eq ! ( trait_did. krate, ast:: LOCAL_CRATE ) ;
12461239 match find_bound_for_assoc_item ( this,
12471240 trait_did. node ,
0 commit comments