-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #6105 - bugadani:sus-char, r=ebroto
Lint for invisible Unicode characters other than ZWSP This PR extends the existing `zero_width_space` lint to look for other invisible characters as well (in this case, `\\u{ad}` soft hyphen. I feel like this lint is the logical place to add the check, but I also realize the lint name is not particularly flexible, but I also understand that it shouldn't be renamed for compatibility reasons. Open questions: - What other characters should trigger the lint? - What should be done with the lint name? - How to indicate the change in functionality? Motivation behind this PR: rust-lang/rust#77417 - I managed to shoot myself in the foot by an invisible character pasted into my test case.
- Loading branch information
Showing
6 changed files
with
47 additions
and
27 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,38 @@ | ||
error: zero-width space detected | ||
error: invisible character detected | ||
--> $DIR/unicode.rs:3:12 | ||
| | ||
LL | print!("Here >< is a ZWS, and another"); | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider replacing the string with: `"Here >/u{200B}< is a ZWS, and /u{200B}another"` | ||
| | ||
= note: `-D clippy::zero-width-space` implied by `-D warnings` | ||
= note: `-D clippy::invisible-characters` implied by `-D warnings` | ||
|
||
error: invisible character detected | ||
--> $DIR/unicode.rs:5:12 | ||
| | ||
LL | print!("Here >< is a SHY, and another"); | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider replacing the string with: `"Here >/u{AD}< is a SHY, and /u{AD}another"` | ||
|
||
error: invisible character detected | ||
--> $DIR/unicode.rs:7:12 | ||
| | ||
LL | print!("Here >< is a WJ, and another"); | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider replacing the string with: `"Here >/u{2060}< is a WJ, and /u{2060}another"` | ||
|
||
error: non-NFC Unicode sequence detected | ||
--> $DIR/unicode.rs:9:12 | ||
--> $DIR/unicode.rs:13:12 | ||
| | ||
LL | print!("̀àh?"); | ||
| ^^^^^ help: consider replacing the string with: `"̀àh?"` | ||
| | ||
= note: `-D clippy::unicode-not-nfc` implied by `-D warnings` | ||
|
||
error: literal non-ASCII character detected | ||
--> $DIR/unicode.rs:15:12 | ||
--> $DIR/unicode.rs:19:12 | ||
| | ||
LL | print!("Üben!"); | ||
| ^^^^^^^ help: consider replacing the string with: `"/u{dc}ben!"` | ||
| | ||
= note: `-D clippy::non-ascii-literal` implied by `-D warnings` | ||
|
||
error: aborting due to 3 previous errors | ||
error: aborting due to 5 previous errors | ||
|