@@ -14,8 +14,7 @@ use rustc_data_structures::fx::FxIndexMap;
14
14
use rustc_data_structures:: sync:: { self , Lrc } ;
15
15
use rustc_errors:: { DiagCtxt , ErrorGuaranteed , PResult } ;
16
16
use rustc_feature:: Features ;
17
- use rustc_lint_defs:: builtin:: PROC_MACRO_BACK_COMPAT ;
18
- use rustc_lint_defs:: { BufferedEarlyLint , BuiltinLintDiag , RegisteredTools } ;
17
+ use rustc_lint_defs:: { BufferedEarlyLint , RegisteredTools } ;
19
18
use rustc_parse:: { parser, MACRO_ARGUMENTS } ;
20
19
use rustc_session:: config:: CollapseMacroDebuginfo ;
21
20
use rustc_session:: { parse:: ParseSess , Limit , Session } ;
@@ -1330,80 +1329,63 @@ pub fn parse_macro_name_and_helper_attrs(
1330
1329
Some ( ( trait_ident. name , proc_attrs) )
1331
1330
}
1332
1331
1333
- /// This nonterminal looks like some specific enums from
1334
- /// `proc-macro-hack` and `procedural-masquerade` crates.
1335
- /// We need to maintain some special pretty-printing behavior for them due to incorrect
1336
- /// asserts in old versions of those crates and their wide use in the ecosystem.
1337
- /// See issue #73345 for more details.
1332
+ /// If this item looks like a specific enums from `rental`, emit a fatal error.
1333
+ /// See #73345 and #83125 for more details.
1338
1334
/// FIXME(#73933): Remove this eventually.
1339
- fn pretty_printing_compatibility_hack ( item : & Item , sess : & Session ) -> bool {
1335
+ fn pretty_printing_compatibility_hack ( item : & Item , sess : & Session ) {
1340
1336
let name = item. ident . name ;
1341
- if name == sym:: ProceduralMasqueradeDummyType {
1342
- if let ast:: ItemKind :: Enum ( enum_def, _) = & item. kind {
1343
- if let [ variant] = & * enum_def. variants {
1344
- if variant. ident . name == sym:: Input {
1345
- let filename = sess. source_map ( ) . span_to_filename ( item. ident . span ) ;
1346
- if let FileName :: Real ( real) = filename {
1347
- if let Some ( c) = real
1348
- . local_path ( )
1349
- . unwrap_or ( Path :: new ( "" ) )
1350
- . components ( )
1351
- . flat_map ( |c| c. as_os_str ( ) . to_str ( ) )
1352
- . find ( |c| c. starts_with ( "rental" ) || c. starts_with ( "allsorts-rental" ) )
1353
- {
1354
- let crate_matches = if c. starts_with ( "allsorts-rental" ) {
1355
- true
1356
- } else {
1357
- let mut version = c. trim_start_matches ( "rental-" ) . split ( '.' ) ;
1358
- version. next ( ) == Some ( "0" )
1359
- && version. next ( ) == Some ( "5" )
1360
- && version
1361
- . next ( )
1362
- . and_then ( |c| c. parse :: < u32 > ( ) . ok ( ) )
1363
- . is_some_and ( |v| v < 6 )
1364
- } ;
1365
-
1366
- if crate_matches {
1367
- sess. psess . buffer_lint (
1368
- PROC_MACRO_BACK_COMPAT ,
1369
- item. ident . span ,
1370
- ast:: CRATE_NODE_ID ,
1371
- BuiltinLintDiag :: ProcMacroBackCompat {
1372
- crate_name : "rental" . to_string ( ) ,
1373
- fixed_version : "0.5.6" . to_string ( ) ,
1374
- } ,
1375
- ) ;
1376
- return true ;
1377
- }
1378
- }
1379
- }
1380
- }
1381
- }
1337
+ if name == sym:: ProceduralMasqueradeDummyType
1338
+ && let ast:: ItemKind :: Enum ( enum_def, _) = & item. kind
1339
+ && let [ variant] = & * enum_def. variants
1340
+ && variant. ident . name == sym:: Input
1341
+ && let FileName :: Real ( real) = sess. source_map ( ) . span_to_filename ( item. ident . span )
1342
+ && let Some ( c) = real
1343
+ . local_path ( )
1344
+ . unwrap_or ( Path :: new ( "" ) )
1345
+ . components ( )
1346
+ . flat_map ( |c| c. as_os_str ( ) . to_str ( ) )
1347
+ . find ( |c| c. starts_with ( "rental" ) || c. starts_with ( "allsorts-rental" ) )
1348
+ {
1349
+ let crate_matches = if c. starts_with ( "allsorts-rental" ) {
1350
+ true
1351
+ } else {
1352
+ let mut version = c. trim_start_matches ( "rental-" ) . split ( '.' ) ;
1353
+ version. next ( ) == Some ( "0" )
1354
+ && version. next ( ) == Some ( "5" )
1355
+ && version. next ( ) . and_then ( |c| c. parse :: < u32 > ( ) . ok ( ) ) . is_some_and ( |v| v < 6 )
1356
+ } ;
1357
+
1358
+ if crate_matches {
1359
+ // FIXME: make this translatable
1360
+ #[ allow( rustc:: untranslatable_diagnostic) ]
1361
+ sess. psess . dcx . emit_fatal ( errors:: ProcMacroBackCompat {
1362
+ crate_name : "rental" . to_string ( ) ,
1363
+ fixed_version : "0.5.6" . to_string ( ) ,
1364
+ } ) ;
1382
1365
}
1383
1366
}
1384
- false
1385
1367
}
1386
1368
1387
- pub ( crate ) fn ann_pretty_printing_compatibility_hack ( ann : & Annotatable , sess : & Session ) -> bool {
1369
+ pub ( crate ) fn ann_pretty_printing_compatibility_hack ( ann : & Annotatable , sess : & Session ) {
1388
1370
let item = match ann {
1389
1371
Annotatable :: Item ( item) => item,
1390
1372
Annotatable :: Stmt ( stmt) => match & stmt. kind {
1391
1373
ast:: StmtKind :: Item ( item) => item,
1392
- _ => return false ,
1374
+ _ => return ,
1393
1375
} ,
1394
- _ => return false ,
1376
+ _ => return ,
1395
1377
} ;
1396
1378
pretty_printing_compatibility_hack ( item, sess)
1397
1379
}
1398
1380
1399
- pub ( crate ) fn nt_pretty_printing_compatibility_hack ( nt : & Nonterminal , sess : & Session ) -> bool {
1381
+ pub ( crate ) fn nt_pretty_printing_compatibility_hack ( nt : & Nonterminal , sess : & Session ) {
1400
1382
let item = match nt {
1401
1383
Nonterminal :: NtItem ( item) => item,
1402
1384
Nonterminal :: NtStmt ( stmt) => match & stmt. kind {
1403
1385
ast:: StmtKind :: Item ( item) => item,
1404
- _ => return false ,
1386
+ _ => return ,
1405
1387
} ,
1406
- _ => return false ,
1388
+ _ => return ,
1407
1389
} ;
1408
1390
pretty_printing_compatibility_hack ( item, sess)
1409
1391
}
0 commit comments