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 @@ -1210,11 +1210,25 @@ impl<'tcx> TyCtxt<'tcx> {
12101210 self . mk_ty ( Error ( DelaySpanBugEmitted ( ( ) ) ) )
12111211 }
12121212
1213- /// Like `err` but for constants.
1213+ /// Like [`ty_error`] but for constants.
12141214 #[ track_caller]
12151215 pub fn const_error ( self , ty : Ty < ' tcx > ) -> & ' tcx Const < ' tcx > {
1216- self . sess
1217- . delay_span_bug ( DUMMY_SP , "ty::ConstKind::Error constructed but no error reported." ) ;
1216+ self . const_error_with_message (
1217+ ty,
1218+ DUMMY_SP ,
1219+ "ty::ConstKind::Error constructed but no error reported" ,
1220+ )
1221+ }
1222+
1223+ /// Like [`ty_error_with_message`] but for constants.
1224+ #[ track_caller]
1225+ pub fn const_error_with_message < S : Into < MultiSpan > > (
1226+ self ,
1227+ ty : Ty < ' tcx > ,
1228+ span : S ,
1229+ msg : & str ,
1230+ ) -> & ' tcx Const < ' tcx > {
1231+ self . sess . delay_span_bug ( span, msg) ;
12181232 self . mk_const ( ty:: Const { val : ty:: ConstKind :: Error ( DelaySpanBugEmitted ( ( ) ) ) , ty } )
12191233 }
12201234
Original file line number Diff line number Diff line change @@ -381,7 +381,7 @@ impl<'tcx> AstConv<'tcx> for ItemCtxt<'tcx> {
381381 }
382382
383383 fn ty_infer ( & self , _: Option < & ty:: GenericParamDef > , span : Span ) -> Ty < ' tcx > {
384- self . tcx ( ) . ty_error_with_message ( span, "bad_placeholder_type " )
384+ self . tcx ( ) . ty_error_with_message ( span, "bad placeholder type " )
385385 }
386386
387387 fn ct_infer (
@@ -390,13 +390,11 @@ impl<'tcx> AstConv<'tcx> for ItemCtxt<'tcx> {
390390 _: Option < & ty:: GenericParamDef > ,
391391 span : Span ,
392392 ) -> & ' tcx Const < ' tcx > {
393- bad_placeholder ( self . tcx ( ) , "const" , vec ! [ span] , "generic" ) . emit ( ) ;
394- // Typeck doesn't expect erased regions to be returned from `type_of`.
395393 let ty = self . tcx . fold_regions ( ty, & mut false , |r, _| match r {
396394 ty:: ReErased => self . tcx . lifetimes . re_static ,
397395 _ => r,
398396 } ) ;
399- self . tcx ( ) . const_error ( ty)
397+ self . tcx ( ) . const_error_with_message ( ty, span , "bad placeholder constant" )
400398 }
401399
402400 fn projected_ty_from_poly_trait_ref (
You can’t perform that action at this time.
0 commit comments