@@ -46,7 +46,7 @@ use rustc_session::lint::{Level, Lint};
46
46
use rustc_session:: Session ;
47
47
use rustc_span:: source_map:: MultiSpan ;
48
48
use rustc_span:: symbol:: { kw, sym, Symbol } ;
49
- use rustc_span:: Span ;
49
+ use rustc_span:: { Span , DUMMY_SP } ;
50
50
use rustc_target:: abi:: { Layout , TargetDataLayout , VariantIdx } ;
51
51
use rustc_target:: spec:: abi;
52
52
@@ -145,7 +145,6 @@ pub struct CommonTypes<'tcx> {
145
145
pub f64 : Ty < ' tcx > ,
146
146
pub never : Ty < ' tcx > ,
147
147
pub self_param : Ty < ' tcx > ,
148
- pub err : Ty < ' tcx > ,
149
148
150
149
/// Dummy type used for the `Self` of a `TraitRef` created for converting
151
150
/// a trait object, and which gets removed in `ExistentialTraitRef`.
@@ -803,7 +802,6 @@ impl<'tcx> CommonTypes<'tcx> {
803
802
bool : mk ( Bool ) ,
804
803
char : mk ( Char ) ,
805
804
never : mk ( Never ) ,
806
- err : mk ( Error ) ,
807
805
isize : mk ( Int ( ast:: IntTy :: Isize ) ) ,
808
806
i8 : mk ( Int ( ast:: IntTy :: I8 ) ) ,
809
807
i16 : mk ( Int ( ast:: IntTy :: I16 ) ) ,
@@ -1142,6 +1140,31 @@ impl<'tcx> TyCtxt<'tcx> {
1142
1140
}
1143
1141
}
1144
1142
1143
+ /// Constructs a `TyKind::Error` type and registers a `delay_span_bug` to ensure it gets used.
1144
+ #[ track_caller]
1145
+ pub fn ty_error ( self ) -> Ty < ' tcx > {
1146
+ self . ty_error_with_message ( DUMMY_SP , "TyKind::Error constructed but no error reported" )
1147
+ }
1148
+
1149
+ /// Constructs a `TyKind::Error` type and registers a `delay_span_bug` with the given `msg to
1150
+ /// ensure it gets used.
1151
+ #[ track_caller]
1152
+ pub fn ty_error_with_message < S : Into < MultiSpan > > ( self , span : S , msg : & str ) -> Ty < ' tcx > {
1153
+ self . sess . delay_span_bug ( span, msg) ;
1154
+ self . mk_ty ( Error ( super :: sty:: DelaySpanBugEmitted ( ( ) ) ) )
1155
+ }
1156
+
1157
+ /// Like `err` but for constants.
1158
+ #[ track_caller]
1159
+ pub fn const_error ( self , ty : Ty < ' tcx > ) -> & ' tcx Const < ' tcx > {
1160
+ self . sess
1161
+ . delay_span_bug ( DUMMY_SP , "ty::ConstKind::Error constructed but no error reported." ) ;
1162
+ self . mk_const ( ty:: Const {
1163
+ val : ty:: ConstKind :: Error ( super :: sty:: DelaySpanBugEmitted ( ( ) ) ) ,
1164
+ ty,
1165
+ } )
1166
+ }
1167
+
1145
1168
pub fn consider_optimizing < T : Fn ( ) -> String > ( & self , msg : T ) -> bool {
1146
1169
let cname = self . crate_name ( LOCAL_CRATE ) . as_str ( ) ;
1147
1170
self . sess . consider_optimizing ( & cname, msg)
@@ -1845,7 +1868,7 @@ macro_rules! sty_debug_print {
1845
1868
let variant = match t. kind {
1846
1869
ty:: Bool | ty:: Char | ty:: Int ( ..) | ty:: Uint ( ..) |
1847
1870
ty:: Float ( ..) | ty:: Str | ty:: Never => continue ,
1848
- ty:: Error => /* unimportant */ continue ,
1871
+ ty:: Error ( _ ) => /* unimportant */ continue ,
1849
1872
$( ty:: $variant( ..) => & mut $variant, ) *
1850
1873
} ;
1851
1874
let lt = t. flags. intersects( ty:: TypeFlags :: HAS_RE_INFER ) ;
0 commit comments