File tree 2 files changed +19
-7
lines changed
2 files changed +19
-7
lines changed Original file line number Diff line number Diff line change @@ -1209,11 +1209,25 @@ impl<'tcx> TyCtxt<'tcx> {
1209
1209
self . mk_ty ( Error ( DelaySpanBugEmitted ( ( ) ) ) )
1210
1210
}
1211
1211
1212
- /// Like `err` but for constants.
1212
+ /// Like [`ty_error`] but for constants.
1213
1213
#[ track_caller]
1214
1214
pub fn const_error ( self , ty : Ty < ' tcx > ) -> & ' tcx Const < ' tcx > {
1215
- self . sess
1216
- . delay_span_bug ( DUMMY_SP , "ty::ConstKind::Error constructed but no error reported." ) ;
1215
+ self . const_error_with_message (
1216
+ ty,
1217
+ DUMMY_SP ,
1218
+ "ty::ConstKind::Error constructed but no error reported" ,
1219
+ )
1220
+ }
1221
+
1222
+ /// Like [`ty_error_with_message`] but for constants.
1223
+ #[ track_caller]
1224
+ pub fn const_error_with_message < S : Into < MultiSpan > > (
1225
+ self ,
1226
+ ty : Ty < ' tcx > ,
1227
+ span : S ,
1228
+ msg : & str ,
1229
+ ) -> & ' tcx Const < ' tcx > {
1230
+ self . sess . delay_span_bug ( span, msg) ;
1217
1231
self . mk_const ( ty:: Const { val : ty:: ConstKind :: Error ( DelaySpanBugEmitted ( ( ) ) ) , ty } )
1218
1232
}
1219
1233
Original file line number Diff line number Diff line change @@ -386,7 +386,7 @@ impl<'tcx> AstConv<'tcx> for ItemCtxt<'tcx> {
386
386
}
387
387
388
388
fn ty_infer ( & self , _: Option < & ty:: GenericParamDef > , span : Span ) -> Ty < ' tcx > {
389
- self . tcx ( ) . ty_error_with_message ( span, "bad_placeholder_type " )
389
+ self . tcx ( ) . ty_error_with_message ( span, "bad placeholder type " )
390
390
}
391
391
392
392
fn ct_infer (
@@ -395,13 +395,11 @@ impl<'tcx> AstConv<'tcx> for ItemCtxt<'tcx> {
395
395
_: Option < & ty:: GenericParamDef > ,
396
396
span : Span ,
397
397
) -> & ' tcx Const < ' tcx > {
398
- bad_placeholder ( self . tcx ( ) , "const" , vec ! [ span] , "generic" ) . emit ( ) ;
399
- // Typeck doesn't expect erased regions to be returned from `type_of`.
400
398
let ty = self . tcx . fold_regions ( ty, & mut false , |r, _| match r {
401
399
ty:: ReErased => self . tcx . lifetimes . re_static ,
402
400
_ => r,
403
401
} ) ;
404
- self . tcx ( ) . const_error ( ty)
402
+ self . tcx ( ) . const_error_with_message ( ty, span , "bad placeholder constant" )
405
403
}
406
404
407
405
fn projected_ty_from_poly_trait_ref (
You can’t perform that action at this time.
0 commit comments