Implement mixed script confusable lint.

This commit is contained in:
Charles Lew 2020-06-23 19:45:13 +08:00
parent ef24faf130
commit 25e864e198
8 changed files with 206 additions and 12 deletions

View file

@ -0,0 +1,20 @@
// check-pass
#![feature(non_ascii_idents)]
#![deny(mixed_script_confusables)]
struct ΑctuallyNotLatin;
fn main() {
let λ = 42; // this usage of Greek confirms that Greek is used intentionally.
}
mod роре {
const : &'static str = "アイウ";
// this usage of Katakana confirms that Katakana is used intentionally.
fn () {
let д: usize = 100; // this usage of Cyrillic confirms that Cyrillic is used intentionally.
println!("meow!");
}
}

View file

@ -0,0 +1,15 @@
#![feature(non_ascii_idents)]
#![deny(mixed_script_confusables)]
struct ΑctuallyNotLatin;
//~^ ERROR The usage of Script Group `Greek` in this crate consists solely of
fn main() {
let v = ΑctuallyNotLatin;
}
mod роре {
//~^ ERROR The usage of Script Group `Cyrillic` in this crate consists solely of
const : &'static str = "アイウ";
//~^ ERROR The usage of Script Group `Japanese, Katakana` in this crate consists solely of
}

View file

@ -0,0 +1,34 @@
error: The usage of Script Group `Greek` in this crate consists solely of mixed script confusables
--> $DIR/lint-mixed-script-confusables.rs:4:8
|
LL | struct ΑctuallyNotLatin;
| ^^^^^^^^^^^^^^^^
|
note: the lint level is defined here
--> $DIR/lint-mixed-script-confusables.rs:2:9
|
LL | #![deny(mixed_script_confusables)]
| ^^^^^^^^^^^^^^^^^^^^^^^^
= note: The usage includes 'Α' (U+0391).
= note: Please recheck to make sure their usages are indeed what you want.
error: The usage of Script Group `Cyrillic` in this crate consists solely of mixed script confusables
--> $DIR/lint-mixed-script-confusables.rs:11:5
|
LL | mod роре {
| ^^^^
|
= note: The usage includes 'е' (U+0435), 'о' (U+043E), 'р' (U+0440).
= note: Please recheck to make sure their usages are indeed what you want.
error: The usage of Script Group `Japanese, Katakana` in this crate consists solely of mixed script confusables
--> $DIR/lint-mixed-script-confusables.rs:13:11
|
LL | const エ: &'static str = "アイウ";
| ^^
|
= note: The usage includes 'エ' (U+30A8).
= note: Please recheck to make sure their usages are indeed what you want.
error: aborting due to 3 previous errors

View file

@ -1,3 +1,5 @@
#![allow(mixed_script_confusables)]
fn foo<
'β, //~ ERROR non-ascii idents are not fully supported
γ //~ ERROR non-ascii idents are not fully supported

View file

@ -1,5 +1,5 @@
error[E0658]: non-ascii idents are not fully supported
--> $DIR/utf8_idents.rs:2:5
--> $DIR/utf8_idents.rs:4:5
|
LL | 'β,
| ^^
@ -8,7 +8,7 @@ LL | 'β,
= help: add `#![feature(non_ascii_idents)]` to the crate attributes to enable
error[E0658]: non-ascii idents are not fully supported
--> $DIR/utf8_idents.rs:3:5
--> $DIR/utf8_idents.rs:5:5
|
LL | γ
| ^
@ -17,7 +17,7 @@ LL | γ
= help: add `#![feature(non_ascii_idents)]` to the crate attributes to enable
error[E0658]: non-ascii idents are not fully supported
--> $DIR/utf8_idents.rs:8:5
--> $DIR/utf8_idents.rs:10:5
|
LL | δ: usize
| ^
@ -26,7 +26,7 @@ LL | δ: usize
= help: add `#![feature(non_ascii_idents)]` to the crate attributes to enable
error[E0658]: non-ascii idents are not fully supported
--> $DIR/utf8_idents.rs:12:9
--> $DIR/utf8_idents.rs:14:9
|
LL | let α = 0.00001f64;
| ^
@ -35,7 +35,7 @@ LL | let α = 0.00001f64;
= help: add `#![feature(non_ascii_idents)]` to the crate attributes to enable
warning: type parameter `γ` should have an upper camel case name
--> $DIR/utf8_idents.rs:3:5
--> $DIR/utf8_idents.rs:5:5
|
LL | γ
| ^ help: convert the identifier to upper camel case: `Γ`