forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement mixed script confusable lint.
- Loading branch information
Showing
8 changed files
with
206 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
src/test/ui/lint/rfc-2457-non-ascii-idents/lint-mixed-script-confusables-2.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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!"); | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
src/test/ui/lint/rfc-2457-non-ascii-idents/lint-mixed-script-confusables.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
} |
34 changes: 34 additions & 0 deletions
34
src/test/ui/lint/rfc-2457-non-ascii-idents/lint-mixed-script-confusables.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters