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> {
1861
1861
}
1862
1862
1863
1863
#[ inline( always) ]
1864
- fn check_and_mk_substs (
1864
+ pub ( crate ) fn check_and_mk_substs (
1865
1865
self ,
1866
1866
_def_id : DefId ,
1867
1867
substs : impl IntoIterator < Item : Into < GenericArg < ' tcx > > > ,
Original file line number Diff line number Diff line change 3
3
#![ allow( rustc:: usage_of_ty_tykind) ]
4
4
5
5
use crate :: infer:: canonical:: Canonical ;
6
+ use crate :: ty:: query:: TyCtxtAt ;
6
7
use crate :: ty:: subst:: { GenericArg , InternalSubsts , SubstsRef } ;
7
8
use crate :: ty:: visit:: ValidateBoundVars ;
8
9
use crate :: ty:: InferTy :: * ;
@@ -825,6 +826,24 @@ pub struct TraitRef<'tcx> {
825
826
}
826
827
827
828
impl < ' 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
+
828
847
pub fn with_self_ty ( self , tcx : TyCtxt < ' tcx > , self_ty : Ty < ' tcx > ) -> Self {
829
848
tcx. mk_trait_ref (
830
849
self . def_id ,
You can’t perform that action at this time.
0 commit comments