Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit a330e49

Browse files
committedJun 4, 2024
Auto merge of #125989 - GuillaumeGomez:rollup-xu69i13, r=GuillaumeGomez
Rollup of 11 pull requests Successful merges: - #106186 (Add function `core::iter::chain`) - #125596 (Convert `proc_macro_back_compat` lint to an unconditional error.) - #125696 (Explain differences between `{Once,Lazy}{Cell,Lock}` types) - #125917 (Create `run-make` `env_var` and `env_var_os` helpers) - #125927 (Ignore `vec_deque_alloc_error::test_shrink_to_unwind` test on non-unwind targets) - #125930 (feat(opt-dist): new flag `--benchmark-cargo-config`) - #125932 (Fix typo in the docs of `HashMap::raw_entry_mut`) - #125933 (Update books) - #125944 (Update fuchsia maintainers) - #125946 (Include trailing commas in wrapped function declarations [RustDoc]) - #125973 (Remove `tests/run-make-fulldeps/pretty-expanded`) Failed merges: - #125815 (`rustc_parse` top-level cleanups) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 23e040a + f41c3e9 commit a330e49

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+318
-762
lines changed
 

‎compiler/rustc_expand/messages.ftl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,9 @@ expand_not_a_meta_item =
124124
expand_only_one_word =
125125
must only be one word
126126
127+
expand_proc_macro_back_compat = using an old version of `{$crate_name}`
128+
.note = older versions of the `{$crate_name}` crate no longer compile; please update to `{$crate_name}` v{$fixed_version}, or switch to one of the `{$crate_name}` alternatives
129+
127130
expand_proc_macro_derive_panicked =
128131
proc-macro derive panicked
129132
.help = message: {$message}

‎compiler/rustc_expand/src/base.rs

Lines changed: 38 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@ use rustc_data_structures::fx::FxIndexMap;
1414
use rustc_data_structures::sync::{self, Lrc};
1515
use rustc_errors::{DiagCtxt, ErrorGuaranteed, PResult};
1616
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};
1918
use rustc_parse::{parser, MACRO_ARGUMENTS};
2019
use rustc_session::config::CollapseMacroDebuginfo;
2120
use rustc_session::{parse::ParseSess, Limit, Session};
@@ -1330,80 +1329,63 @@ pub fn parse_macro_name_and_helper_attrs(
13301329
Some((trait_ident.name, proc_attrs))
13311330
}
13321331

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.
13381334
/// 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) {
13401336
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+
});
13821365
}
13831366
}
1384-
false
13851367
}
13861368

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) {
13881370
let item = match ann {
13891371
Annotatable::Item(item) => item,
13901372
Annotatable::Stmt(stmt) => match &stmt.kind {
13911373
ast::StmtKind::Item(item) => item,
1392-
_ => return false,
1374+
_ => return,
13931375
},
1394-
_ => return false,
1376+
_ => return,
13951377
};
13961378
pretty_printing_compatibility_hack(item, sess)
13971379
}
13981380

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) {
14001382
let item = match nt {
14011383
Nonterminal::NtItem(item) => item,
14021384
Nonterminal::NtStmt(stmt) => match &stmt.kind {
14031385
ast::StmtKind::Item(item) => item,
1404-
_ => return false,
1386+
_ => return,
14051387
},
1406-
_ => return false,
1388+
_ => return,
14071389
};
14081390
pretty_printing_compatibility_hack(item, sess)
14091391
}

0 commit comments

Comments
 (0)
Please sign in to comment.