@@ -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`.
@@ -804,7 +803,6 @@ impl<'tcx> CommonTypes<'tcx> {
804
803
bool : mk ( Bool ) ,
805
804
char : mk ( Char ) ,
806
805
never : mk ( Never ) ,
807
- err : mk ( Error ) ,
808
806
isize : mk ( Int ( ast:: IntTy :: Isize ) ) ,
809
807
i8 : mk ( Int ( ast:: IntTy :: I8 ) ) ,
810
808
i16 : mk ( Int ( ast:: IntTy :: I16 ) ) ,
@@ -1143,6 +1141,49 @@ impl<'tcx> TyCtxt<'tcx> {
1143
1141
}
1144
1142
}
1145
1143
1144
+ /// Constructs a `TyKind::Error` type and registers a `delay_span_bug` to ensure it gets used.
1145
+ #[ track_caller]
1146
+ pub fn ty_error ( self ) -> Ty < ' tcx > {
1147
+ self . err_with_message_and_location (
1148
+ DUMMY_SP ,
1149
+ "TyKind::Error constructed but no error reported" ,
1150
+ std:: panic:: Location :: caller ( ) ,
1151
+ )
1152
+ }
1153
+
1154
+ /// Constructs a `TyKind::Error` type and registers a `delay_span_bug` with the given `msg to
1155
+ /// ensure it gets used.
1156
+ #[ track_caller]
1157
+ pub fn ty_error_with_message < S : Into < MultiSpan > > ( self , span : S , msg : & str ) -> Ty < ' tcx > {
1158
+ self . err_with_message_and_location ( span, msg, std:: panic:: Location :: caller ( ) )
1159
+ }
1160
+
1161
+ pub fn err_with_message_and_location < S : Into < MultiSpan > > (
1162
+ self ,
1163
+ span : S ,
1164
+ msg : & str ,
1165
+ loc : & ' static std:: panic:: Location < ' static > ,
1166
+ ) -> Ty < ' tcx > {
1167
+ self . sess . delay_span_bug ( span, & format ! ( "{}: {}" , loc, msg) ) ;
1168
+ self . mk_ty ( Error ( super :: sty:: DelaySpanBugEmitted ( ( ) ) ) )
1169
+ }
1170
+
1171
+ /// Like `err` but for constants.
1172
+ #[ track_caller]
1173
+ pub fn const_error ( self , ty : Ty < ' tcx > ) -> & ' tcx Const < ' tcx > {
1174
+ self . sess . delay_span_bug (
1175
+ DUMMY_SP ,
1176
+ & format ! (
1177
+ "ty::ConstKind::Error constructed but no error reported. {}" ,
1178
+ std:: panic:: Location :: caller( )
1179
+ ) ,
1180
+ ) ;
1181
+ self . mk_const ( ty:: Const {
1182
+ val : ty:: ConstKind :: Error ( super :: sty:: DelaySpanBugEmitted ( ( ) ) ) ,
1183
+ ty,
1184
+ } )
1185
+ }
1186
+
1146
1187
pub fn consider_optimizing < T : Fn ( ) -> String > ( & self , msg : T ) -> bool {
1147
1188
let cname = self . crate_name ( LOCAL_CRATE ) . as_str ( ) ;
1148
1189
self . sess . consider_optimizing ( & cname, msg)
@@ -1846,7 +1887,7 @@ macro_rules! sty_debug_print {
1846
1887
let variant = match t. kind {
1847
1888
ty:: Bool | ty:: Char | ty:: Int ( ..) | ty:: Uint ( ..) |
1848
1889
ty:: Float ( ..) | ty:: Str | ty:: Never => continue ,
1849
- ty:: Error => /* unimportant */ continue ,
1890
+ ty:: Error ( _ ) => /* unimportant */ continue ,
1850
1891
$( ty:: $variant( ..) => & mut $variant, ) *
1851
1892
} ;
1852
1893
let lt = t. flags. intersects( ty:: TypeFlags :: HAS_RE_INFER ) ;
0 commit comments