11use std:: mem;
22
3- use rustc_errors:: { DiagArgName , DiagArgValue , DiagMessage , Diagnostic , IntoDiagArg } ;
3+ use rustc_errors:: { Diag , DiagArgName , DiagArgValue , DiagMessage , IntoDiagArg } ;
44use rustc_middle:: mir:: AssertKind ;
55use rustc_middle:: mir:: interpret:: { Provenance , ReportedErrorInfo } ;
66use rustc_middle:: query:: TyCtxtAt ;
@@ -134,7 +134,7 @@ pub fn get_span_and_frames<'tcx>(
134134/// This will use the `mk` function for creating the error which will get passed labels according to
135135/// the `InterpError` and the span and a stacktrace of current execution according to
136136/// `get_span_and_frames`.
137- pub ( super ) fn report < ' tcx , C , F , E > (
137+ pub ( super ) fn report < ' tcx , C , F > (
138138 tcx : TyCtxt < ' tcx > ,
139139 error : InterpErrorKind < ' tcx > ,
140140 span : Span ,
@@ -143,8 +143,7 @@ pub(super) fn report<'tcx, C, F, E>(
143143) -> ErrorHandled
144144where
145145 C : FnOnce ( ) -> ( Span , Vec < FrameNote > ) ,
146- F : FnOnce ( Span , Vec < FrameNote > ) -> E ,
147- E : Diagnostic < ' tcx > ,
146+ F : FnOnce ( & mut Diag < ' _ > , Span , Vec < FrameNote > ) ,
148147{
149148 // Special handling for certain errors
150149 match error {
@@ -163,20 +162,17 @@ where
163162 _ => {
164163 let ( our_span, frames) = get_span_and_frames ( ) ;
165164 let span = span. substitute_dummy ( our_span) ;
166- let err = mk ( span, frames) ;
167- let mut err = tcx. dcx ( ) . create_err ( err) ;
165+ let mut err = tcx. dcx ( ) . struct_span_err ( our_span, error. diagnostic_message ( ) ) ;
168166 // We allow invalid programs in infallible promoteds since invalid layouts can occur
169167 // anyway (e.g. due to size overflow). And we allow OOM as that can happen any time.
170168 let allowed_in_infallible = matches ! (
171169 error,
172170 InterpErrorKind :: ResourceExhaustion ( _) | InterpErrorKind :: InvalidProgram ( _)
173171 ) ;
174172
175- let msg = error. diagnostic_message ( ) ;
176173 error. add_args ( & mut err) ;
177174
178- // Use *our* span to label the interp error
179- err. span_label ( our_span, msg) ;
175+ mk ( & mut err, span, frames) ;
180176 let g = err. emit ( ) ;
181177 let reported = if allowed_in_infallible {
182178 ReportedErrorInfo :: allowed_in_infallible ( g)
0 commit comments