@@ -4,7 +4,9 @@ use rustc_errors::{
4
4
} ;
5
5
use rustc_macros:: { Diagnostic , LintDiagnostic , Subdiagnostic } ;
6
6
use rustc_middle:: mir:: { AssertKind , UnsafetyViolationDetails } ;
7
+ use rustc_middle:: ty:: TyCtxt ;
7
8
use rustc_session:: lint:: { self , Lint } ;
9
+ use rustc_span:: def_id:: DefId ;
8
10
use rustc_span:: Span ;
9
11
10
12
#[ derive( LintDiagnostic ) ]
@@ -237,20 +239,38 @@ pub(crate) struct FnItemRef {
237
239
pub ident : String ,
238
240
}
239
241
240
- #[ derive( LintDiagnostic ) ]
241
- #[ diag( mir_transform_must_not_suspend) ]
242
- pub ( crate ) struct MustNotSupend < ' a > {
243
- #[ label]
242
+ pub ( crate ) struct MustNotSupend < ' tcx , ' a > {
243
+ pub tcx : TyCtxt < ' tcx > ,
244
244
pub yield_sp : Span ,
245
- #[ subdiagnostic]
246
245
pub reason : Option < MustNotSuspendReason > ,
247
- #[ help]
248
246
pub src_sp : Span ,
249
247
pub pre : & ' a str ,
250
- pub def_path : String ,
248
+ pub def_id : DefId ,
251
249
pub post : & ' a str ,
252
250
}
253
251
252
+ // Needed for def_path_str
253
+ impl < ' a > DecorateLint < ' a , ( ) > for MustNotSupend < ' _ , ' _ > {
254
+ fn decorate_lint < ' b > (
255
+ self ,
256
+ diag : & ' b mut rustc_errors:: DiagnosticBuilder < ' a , ( ) > ,
257
+ ) -> & ' b mut rustc_errors:: DiagnosticBuilder < ' a , ( ) > {
258
+ diag. span_label ( self . yield_sp , crate :: fluent_generated:: _subdiag:: label) ;
259
+ if let Some ( reason) = self . reason {
260
+ diag. subdiagnostic ( reason) ;
261
+ }
262
+ diag. span_help ( self . src_sp , crate :: fluent_generated:: _subdiag:: help) ;
263
+ diag. set_arg ( "pre" , self . pre ) ;
264
+ diag. set_arg ( "def_path" , self . tcx . def_path_str ( self . def_id ) ) ;
265
+ diag. set_arg ( "post" , self . post ) ;
266
+ diag
267
+ }
268
+
269
+ fn msg ( & self ) -> rustc_errors:: DiagnosticMessage {
270
+ crate :: fluent_generated:: mir_transform_must_not_suspend
271
+ }
272
+ }
273
+
254
274
#[ derive( Subdiagnostic ) ]
255
275
#[ note( mir_transform_note) ]
256
276
pub ( crate ) struct MustNotSuspendReason {
0 commit comments