File tree 1 file changed +9
-1
lines changed
compiler/rustc_middle/src/ty
1 file changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -1132,8 +1132,16 @@ impl<'tcx> ProjectionTy<'tcx> {
1132
1132
/// For example, if this is a projection of `<T as Iterator>::Item`,
1133
1133
/// then this function would return a `T: Iterator` trait reference.
1134
1134
pub fn trait_ref ( & self , tcx : TyCtxt < ' tcx > ) -> ty:: TraitRef < ' tcx > {
1135
+ // FIXME: This method probably shouldn't exist at all, since it's not
1136
+ // clear what this method really intends to do. Be careful when
1137
+ // using this method since the resulting TraitRef additionally
1138
+ // contains the substs for the assoc_item, which strictly speaking
1139
+ // is not correct
1135
1140
let def_id = tcx. associated_item ( self . item_def_id ) . container . id ( ) ;
1136
- ty:: TraitRef { def_id, substs : self . substs . truncate_to ( tcx, tcx. generics_of ( def_id) ) }
1141
+ // Include substitutions for generic arguments of associated types
1142
+ let assoc_item = tcx. associated_item ( self . item_def_id ) ;
1143
+ let substs_assoc_item = self . substs . truncate_to ( tcx, tcx. generics_of ( assoc_item. def_id ) ) ;
1144
+ ty:: TraitRef { def_id, substs : substs_assoc_item }
1137
1145
}
1138
1146
1139
1147
pub fn self_ty ( & self ) -> Ty < ' tcx > {
You can’t perform that action at this time.
0 commit comments