Files
rust/compiler/rustc_parse/src
Jonathan Brouwer dd9c329207 Rollup merge of #161792 - fmease:fix-reserved-prefixes-lint-diags, r=mejrs
Fix and improve diagnostics for lint `rust_2021_prefixes_incompatible_syntax`

On main, when encountering token sequences in Rust <2021 that would get interpreted as...

1. ...C string literals in Rust >=2021,
   1. we report "*prefix `c` is unknown*" / "*prefix `cr` is unknown*" despite them obviously being known
   2. we claim that they "*[are] a hard error in Rust 2021*"
2. ...raw lifetimes in Rust >=2021 like `'r#a`, we suggest splitting them *after* the hash (so `'r#` and `a`) which obviously doesn't fix the issue; they need to be split *before* the hash (so `'r` and `#a`)
3. ...unknown (reserved) prefixes in Rust >=2021, we report "*prefix […] is unknown*" but to be pedantic the sequence is *not* a prefix in the current edition, it's just a normal identifier; to be correct & precise we should thus say that they *will* be parsed as a prefix (in Rust >=2021)

Lastly, unify / streamline all diagnostics pertaining to "reserved prefixes" (identifier/literal prefixes, hash prefixes (aka guarded string prefixes / multihashes))

---

Best reviewed commit by commit.

> [!NOTE]
> **Unblocks** PR https://github.com/rust-lang/rust/pull/161775.

<sub>(No LLM was or will be used by me during the entire creation process of this PR)</sub>
2026-08-30 21:48:05 +02:00
..