@@ -4,7 +4,9 @@ use rustc_errors::{
44} ;
55use rustc_macros:: { Diagnostic , LintDiagnostic , Subdiagnostic } ;
66use rustc_middle:: mir:: { AssertKind , UnsafetyViolationDetails } ;
7+ use rustc_middle:: ty:: TyCtxt ;
78use rustc_session:: lint:: { self , Lint } ;
9+ use rustc_span:: def_id:: DefId ;
810use rustc_span:: Span ;
911
1012#[ derive( LintDiagnostic ) ]
@@ -237,20 +239,38 @@ pub(crate) struct FnItemRef {
237239 pub ident : String ,
238240}
239241
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 > ,
244244 pub yield_sp : Span ,
245- #[ subdiagnostic]
246245 pub reason : Option < MustNotSuspendReason > ,
247- #[ help]
248246 pub src_sp : Span ,
249247 pub pre : & ' a str ,
250- pub def_path : String ,
248+ pub def_id : DefId ,
251249 pub post : & ' a str ,
252250}
253251
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+
254274#[ derive( Subdiagnostic ) ]
255275#[ note( mir_transform_note) ]
256276pub ( crate ) struct MustNotSuspendReason {
0 commit comments