@@ -1340,40 +1340,95 @@ pub struct SuspiciousDoubleRefCloneDiag<'a> {
1340
1340
}
1341
1341
1342
1342
// non_local_defs.rs
1343
- #[ derive( LintDiagnostic ) ]
1344
1343
pub enum NonLocalDefinitionsDiag {
1345
- #[ diag( lint_non_local_definitions_impl) ]
1346
- #[ help]
1347
- #[ note( lint_non_local) ]
1348
- #[ note( lint_exception) ]
1349
- #[ note( lint_non_local_definitions_deprecation) ]
1350
1344
Impl {
1351
1345
depth : u32 ,
1352
1346
body_kind_descr : & ' static str ,
1353
1347
body_name : String ,
1354
- #[ subdiagnostic]
1355
1348
cargo_update : Option < NonLocalDefinitionsCargoUpdateNote > ,
1356
- #[ suggestion( lint_const_anon, code = "_" , applicability = "machine-applicable" ) ]
1357
1349
const_anon : Option < Span > ,
1358
1350
} ,
1359
- #[ diag( lint_non_local_definitions_macro_rules) ]
1360
1351
MacroRules {
1361
1352
depth : u32 ,
1362
1353
body_kind_descr : & ' static str ,
1363
1354
body_name : String ,
1364
- #[ help]
1365
1355
help : Option < ( ) > ,
1366
- #[ help( lint_help_doctest) ]
1367
1356
doctest_help : Option < ( ) > ,
1368
- #[ note( lint_non_local) ]
1369
- #[ note( lint_exception) ]
1370
- #[ note( lint_non_local_definitions_deprecation) ]
1371
- notes : ( ) ,
1372
- #[ subdiagnostic]
1373
1357
cargo_update : Option < NonLocalDefinitionsCargoUpdateNote > ,
1374
1358
} ,
1375
1359
}
1376
1360
1361
+ impl < ' a > LintDiagnostic < ' a , ( ) > for NonLocalDefinitionsDiag {
1362
+ fn decorate_lint < ' b > ( self , diag : & ' b mut Diag < ' a , ( ) > ) {
1363
+ match self {
1364
+ NonLocalDefinitionsDiag :: Impl {
1365
+ depth,
1366
+ body_kind_descr,
1367
+ body_name,
1368
+ cargo_update,
1369
+ const_anon,
1370
+ } => {
1371
+ diag. arg ( "depth" , depth) ;
1372
+ diag. arg ( "body_kind_descr" , body_kind_descr) ;
1373
+ diag. arg ( "body_name" , body_name) ;
1374
+
1375
+ diag. help ( fluent:: lint_help) ;
1376
+ diag. note ( fluent:: lint_non_local) ;
1377
+ diag. note ( fluent:: lint_exception) ;
1378
+ diag. note ( fluent:: lint_non_local_definitions_deprecation) ;
1379
+
1380
+ if let Some ( cargo_update) = cargo_update {
1381
+ diag. subdiagnostic ( & diag. dcx , cargo_update) ;
1382
+ }
1383
+ if let Some ( const_anon) = const_anon {
1384
+ diag. span_suggestion (
1385
+ const_anon,
1386
+ fluent:: lint_const_anon,
1387
+ "_" ,
1388
+ Applicability :: MachineApplicable ,
1389
+ ) ;
1390
+ }
1391
+ }
1392
+ NonLocalDefinitionsDiag :: MacroRules {
1393
+ depth,
1394
+ body_kind_descr,
1395
+ body_name,
1396
+ help,
1397
+ doctest_help,
1398
+ cargo_update,
1399
+ } => {
1400
+ diag. arg ( "depth" , depth) ;
1401
+ diag. arg ( "body_kind_descr" , body_kind_descr) ;
1402
+ diag. arg ( "body_name" , body_name) ;
1403
+
1404
+ if let Some ( ( ) ) = help {
1405
+ diag. help ( fluent:: lint_help) ;
1406
+ }
1407
+ if let Some ( ( ) ) = doctest_help {
1408
+ diag. help ( fluent:: lint_help_doctest) ;
1409
+ }
1410
+
1411
+ diag. note ( fluent:: lint_non_local) ;
1412
+ diag. note ( fluent:: lint_exception) ;
1413
+ diag. note ( fluent:: lint_non_local_definitions_deprecation) ;
1414
+
1415
+ if let Some ( cargo_update) = cargo_update {
1416
+ diag. subdiagnostic ( & diag. dcx , cargo_update) ;
1417
+ }
1418
+ }
1419
+ }
1420
+ }
1421
+
1422
+ fn msg ( & self ) -> DiagMessage {
1423
+ match self {
1424
+ NonLocalDefinitionsDiag :: Impl { .. } => fluent:: lint_non_local_definitions_impl,
1425
+ NonLocalDefinitionsDiag :: MacroRules { .. } => {
1426
+ fluent:: lint_non_local_definitions_macro_rules
1427
+ }
1428
+ }
1429
+ }
1430
+ }
1431
+
1377
1432
#[ derive( Subdiagnostic ) ]
1378
1433
#[ note( lint_non_local_definitions_cargo_update) ]
1379
1434
pub struct NonLocalDefinitionsCargoUpdateNote {
0 commit comments