This repository was archived by the owner on May 28, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +20
-1
lines changed
compiler/rustc_middle/src/ty Expand file tree Collapse file tree 2 files changed +20
-1
lines changed Original file line number Diff line number Diff line change @@ -1861,7 +1861,7 @@ impl<'tcx> TyCtxt<'tcx> {
18611861 }
18621862
18631863 #[ inline( always) ]
1864- fn check_and_mk_substs (
1864+ pub ( crate ) fn check_and_mk_substs (
18651865 self ,
18661866 _def_id : DefId ,
18671867 substs : impl IntoIterator < Item : Into < GenericArg < ' tcx > > > ,
Original file line number Diff line number Diff line change 33#![ allow( rustc:: usage_of_ty_tykind) ]
44
55use crate :: infer:: canonical:: Canonical ;
6+ use crate :: ty:: query:: TyCtxtAt ;
67use crate :: ty:: subst:: { GenericArg , InternalSubsts , SubstsRef } ;
78use crate :: ty:: visit:: ValidateBoundVars ;
89use crate :: ty:: InferTy :: * ;
@@ -825,6 +826,24 @@ pub struct TraitRef<'tcx> {
825826}
826827
827828impl < ' tcx > TraitRef < ' tcx > {
829+ pub fn new (
830+ tcx : TyCtxt < ' tcx > ,
831+ trait_def_id : DefId ,
832+ substs : impl IntoIterator < Item : Into < GenericArg < ' tcx > > > ,
833+ ) -> Self {
834+ let substs = tcx. check_and_mk_substs ( trait_def_id, substs) ;
835+ Self { def_id : trait_def_id, substs, _use_mk_trait_ref_instead : ( ) }
836+ }
837+
838+ pub fn from_lang_item (
839+ tcx : TyCtxtAt < ' tcx > ,
840+ trait_lang_item : LangItem ,
841+ substs : impl IntoIterator < Item : Into < ty:: GenericArg < ' tcx > > > ,
842+ ) -> Self {
843+ let trait_def_id = tcx. require_lang_item ( trait_lang_item, Some ( tcx. span ) ) ;
844+ Self :: new ( tcx. tcx , trait_def_id, substs)
845+ }
846+
828847 pub fn with_self_ty ( self , tcx : TyCtxt < ' tcx > , self_ty : Ty < ' tcx > ) -> Self {
829848 tcx. mk_trait_ref (
830849 self . def_id ,
You can’t perform that action at this time.
0 commit comments