File tree Expand file tree Collapse file tree 2 files changed +19
-7
lines changed Expand file tree Collapse file tree 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> {
12091209 self . mk_ty ( Error ( DelaySpanBugEmitted ( ( ) ) ) )
12101210 }
12111211
1212- /// Like `err` but for constants.
1212+ /// Like [`ty_error`] but for constants.
12131213 #[ track_caller]
12141214 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) ;
12171231 self . mk_const ( ty:: Const { val : ty:: ConstKind :: Error ( DelaySpanBugEmitted ( ( ) ) ) , ty } )
12181232 }
12191233
Original file line number Diff line number Diff line change @@ -386,7 +386,7 @@ impl<'tcx> AstConv<'tcx> for ItemCtxt<'tcx> {
386386 }
387387
388388 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 " )
390390 }
391391
392392 fn ct_infer (
@@ -395,13 +395,11 @@ impl<'tcx> AstConv<'tcx> for ItemCtxt<'tcx> {
395395 _: Option < & ty:: GenericParamDef > ,
396396 span : Span ,
397397 ) -> & ' 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`.
400398 let ty = self . tcx . fold_regions ( ty, & mut false , |r, _| match r {
401399 ty:: ReErased => self . tcx . lifetimes . re_static ,
402400 _ => r,
403401 } ) ;
404- self . tcx ( ) . const_error ( ty)
402+ self . tcx ( ) . const_error_with_message ( ty, span , "bad placeholder constant" )
405403 }
406404
407405 fn projected_ty_from_poly_trait_ref (
You can’t perform that action at this time.
0 commit comments