@@ -13,13 +13,14 @@ use crate::middle::stability;
13
13
use crate :: mir:: interpret:: { self , Allocation , ConstValue , Scalar } ;
14
14
use crate :: mir:: { Body , Field , Local , Place , PlaceElem , ProjectionKind , Promoted } ;
15
15
use crate :: traits;
16
+ use crate :: ty:: query:: { self , TyCtxtAt } ;
16
17
use crate :: ty:: steal:: Steal ;
17
18
use crate :: ty:: subst:: { GenericArg , GenericArgKind , InternalSubsts , Subst , SubstsRef , UserSubsts } ;
18
19
use crate :: ty:: TyKind :: * ;
19
20
use 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 ,
23
24
ProjectionTy , Region , RegionKind , ReprOptions , TraitObjectVisitor , Ty , TyKind , TyS , TyVar ,
24
25
TyVid , TypeAndMut ,
25
26
} ;
@@ -2652,6 +2653,21 @@ impl<'tcx> TyCtxt<'tcx> {
2652
2653
}
2653
2654
}
2654
2655
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
+
2655
2671
pub trait InternAs < T : ?Sized , R > {
2656
2672
type Output ;
2657
2673
fn intern_with < F > ( self , f : F ) -> Self :: Output
0 commit comments