mirror of
https://github.com/allankoechke/rust.git
synced 2026-11-30 11:05:36 +00:00
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>