@@ -818,14 +818,10 @@ pub struct TraitRef<'tcx> {
818
818
pub substs : SubstsRef < ' tcx > ,
819
819
/// This field exists to prevent the creation of `TraitRef` without
820
820
/// calling [TyCtxt::mk_trait_ref].
821
- _use_mk_trait_ref_instead : ( ) ,
821
+ pub ( super ) _use_mk_trait_ref_instead : ( ) ,
822
822
}
823
823
824
824
impl < ' tcx > TraitRef < ' tcx > {
825
- pub fn new ( def_id : DefId , substs : SubstsRef < ' tcx > ) -> TraitRef < ' tcx > {
826
- TraitRef { def_id, substs, _use_mk_trait_ref_instead : ( ) }
827
- }
828
-
829
825
pub fn with_self_ty ( self , tcx : TyCtxt < ' tcx > , self_ty : Ty < ' tcx > ) -> Self {
830
826
tcx. mk_trait_ref (
831
827
self . def_id ,
@@ -836,11 +832,7 @@ impl<'tcx> TraitRef<'tcx> {
836
832
/// Returns a `TraitRef` of the form `P0: Foo<P1..Pn>` where `Pi`
837
833
/// are the parameters defined on trait.
838
834
pub fn identity ( tcx : TyCtxt < ' tcx > , def_id : DefId ) -> Binder < ' tcx , TraitRef < ' tcx > > {
839
- ty:: Binder :: dummy ( TraitRef {
840
- def_id,
841
- substs : InternalSubsts :: identity_for_item ( tcx, def_id) ,
842
- _use_mk_trait_ref_instead : ( ) ,
843
- } )
835
+ ty:: Binder :: dummy ( tcx. mk_trait_ref ( def_id, InternalSubsts :: identity_for_item ( tcx, def_id) ) )
844
836
}
845
837
846
838
#[ inline]
@@ -854,11 +846,7 @@ impl<'tcx> TraitRef<'tcx> {
854
846
substs : SubstsRef < ' tcx > ,
855
847
) -> ty:: TraitRef < ' tcx > {
856
848
let defs = tcx. generics_of ( trait_id) ;
857
- ty:: TraitRef {
858
- def_id : trait_id,
859
- substs : tcx. intern_substs ( & substs[ ..defs. params . len ( ) ] ) ,
860
- _use_mk_trait_ref_instead : ( ) ,
861
- }
849
+ tcx. mk_trait_ref ( trait_id, tcx. intern_substs ( & substs[ ..defs. params . len ( ) ] ) )
862
850
}
863
851
}
864
852
0 commit comments