Skip to content

Commit 428208e

Browse files
authored
Fix disallowed_script_idents FP on identifiers with _ (#15123)
Closes #15116 The cause for this issue is that `_` belongs to the `Common` catagory in unicode instead of `Latin` like other ASCII alphabets. Since ASCII characters are always allowed, I just added an extra `is_ascii()` check to ensure this. changelog: [`disallowed_script_idents`] fix FP on identifiers with `_`
2 parents 8633bcb + 7e406e2 commit 428208e

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

clippy_lints/src/disallowed_script_idents.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,10 @@ impl EarlyLintPass for DisallowedScriptIdents {
8989
// Fast path for ascii-only idents.
9090
if !symbol_str.is_ascii()
9191
&& let Some(script) = symbol_str.chars().find_map(|c| {
92+
if c.is_ascii() {
93+
return None;
94+
}
95+
9296
c.script_extension()
9397
.iter()
9498
.find(|script| !self.whitelist.contains(script))

tests/ui/disallowed_script_idents.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,17 @@ fn main() {
1515
let カウンタ = 10;
1616
//~^ disallowed_script_idents
1717
}
18+
19+
fn issue15116() {
20+
const ÄÖÜ: u8 = 0;
21+
const _ÄÖÜ: u8 = 0;
22+
const Ä_ÖÜ: u8 = 0;
23+
const ÄÖ_Ü: u8 = 0;
24+
const ÄÖÜ_: u8 = 0;
25+
let äöüß = 1;
26+
let _äöüß = 1;
27+
let ä_öüß = 1;
28+
let äö_üß = 1;
29+
let äöü_ß = 1;
30+
let äöüß_ = 1;
31+
}

0 commit comments

Comments
 (0)