@@ -13,13 +13,14 @@ use crate::middle::stability;
1313use crate :: mir:: interpret:: { self , Allocation , ConstValue , Scalar } ;
1414use crate :: mir:: { Body , Field , Local , Place , PlaceElem , ProjectionKind , Promoted } ;
1515use crate :: traits;
16+ use crate :: ty:: query:: { self , TyCtxtAt } ;
1617use crate :: ty:: steal:: Steal ;
1718use crate :: ty:: subst:: { GenericArg , GenericArgKind , InternalSubsts , Subst , SubstsRef , UserSubsts } ;
1819use crate :: ty:: TyKind :: * ;
1920use crate :: ty:: {
20- self , query , AdtDef , AdtKind , BindingMode , BoundVar , CanonicalPolyFnSig , Const , ConstVid ,
21- DefIdTree , ExistentialPredicate , FloatVar , FloatVid , GenericParamDefKind , InferConst , InferTy ,
22- IntVar , IntVid , List , ParamConst , ParamTy , PolyFnSig , Predicate , PredicateInner , PredicateKind ,
21+ self , AdtDef , AdtKind , BindingMode , BoundVar , CanonicalPolyFnSig , Const , ConstVid , DefIdTree ,
22+ ExistentialPredicate , FloatVar , FloatVid , GenericParamDefKind , InferConst , InferTy , IntVar ,
23+ IntVid , List , ParamConst , ParamTy , PolyFnSig , Predicate , PredicateInner , PredicateKind ,
2324 ProjectionTy , Region , RegionKind , ReprOptions , TraitObjectVisitor , Ty , TyKind , TyS , TyVar ,
2425 TyVid , TypeAndMut ,
2526} ;
@@ -2652,6 +2653,21 @@ impl<'tcx> TyCtxt<'tcx> {
26522653 }
26532654}
26542655
2656+ impl TyCtxtAt < ' tcx > {
2657+ /// Constructs a `TyKind::Error` type and registers a `delay_span_bug` to ensure it gets used.
2658+ #[ track_caller]
2659+ pub fn ty_error ( self ) -> Ty < ' tcx > {
2660+ self . tcx . ty_error_with_message ( self . span , "TyKind::Error constructed but no error reported" )
2661+ }
2662+
2663+ /// Constructs a `TyKind::Error` type and registers a `delay_span_bug` with the given `msg to
2664+ /// ensure it gets used.
2665+ #[ track_caller]
2666+ pub fn ty_error_with_message ( self , msg : & str ) -> Ty < ' tcx > {
2667+ self . tcx . ty_error_with_message ( self . span , msg)
2668+ }
2669+ }
2670+
26552671pub trait InternAs < T : ?Sized , R > {
26562672 type Output ;
26572673 fn intern_with < F > ( self , f : F ) -> Self :: Output
0 commit comments