@@ -844,11 +844,13 @@ impl<'tcx> TraitRef<'tcx> {
844
844
Self :: new ( tcx. tcx , trait_def_id, substs)
845
845
}
846
846
847
- pub fn with_self_ty ( self , tcx : TyCtxt < ' tcx > , self_ty : Ty < ' tcx > ) -> Self {
848
- tcx. mk_trait_ref (
849
- self . def_id ,
850
- [ self_ty. into ( ) ] . into_iter ( ) . chain ( self . substs . iter ( ) . skip ( 1 ) ) ,
851
- )
847
+ pub fn from_method (
848
+ tcx : TyCtxt < ' tcx > ,
849
+ trait_id : DefId ,
850
+ substs : SubstsRef < ' tcx > ,
851
+ ) -> ty:: TraitRef < ' tcx > {
852
+ let defs = tcx. generics_of ( trait_id) ;
853
+ tcx. mk_trait_ref ( trait_id, tcx. mk_substs ( & substs[ ..defs. params . len ( ) ] ) )
852
854
}
853
855
854
856
/// Returns a `TraitRef` of the form `P0: Foo<P1..Pn>` where `Pi`
@@ -857,19 +859,17 @@ impl<'tcx> TraitRef<'tcx> {
857
859
ty:: Binder :: dummy ( tcx. mk_trait_ref ( def_id, InternalSubsts :: identity_for_item ( tcx, def_id) ) )
858
860
}
859
861
862
+ pub fn with_self_ty ( self , tcx : TyCtxt < ' tcx > , self_ty : Ty < ' tcx > ) -> Self {
863
+ tcx. mk_trait_ref (
864
+ self . def_id ,
865
+ [ self_ty. into ( ) ] . into_iter ( ) . chain ( self . substs . iter ( ) . skip ( 1 ) ) ,
866
+ )
867
+ }
868
+
860
869
#[ inline]
861
870
pub fn self_ty ( & self ) -> Ty < ' tcx > {
862
871
self . substs . type_at ( 0 )
863
872
}
864
-
865
- pub fn from_method (
866
- tcx : TyCtxt < ' tcx > ,
867
- trait_id : DefId ,
868
- substs : SubstsRef < ' tcx > ,
869
- ) -> ty:: TraitRef < ' tcx > {
870
- let defs = tcx. generics_of ( trait_id) ;
871
- tcx. mk_trait_ref ( trait_id, tcx. mk_substs ( & substs[ ..defs. params . len ( ) ] ) )
872
- }
873
873
}
874
874
875
875
pub type PolyTraitRef < ' tcx > = Binder < ' tcx , TraitRef < ' tcx > > ;
0 commit comments