Skip to content

Commit

Permalink
add note
Browse files Browse the repository at this point in the history
  • Loading branch information
HTGAzureX1212 committed Feb 15, 2024
1 parent de88a4d commit 2f6e822
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 12 deletions.
32 changes: 24 additions & 8 deletions compiler/rustc_lint/messages.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -242,20 +242,36 @@ lint_identifier_non_ascii_char = identifier contains non-ASCII characters
lint_identifier_uncommon_codepoints = identifier contains {$codepoints_len ->
[one] { $identifier_type ->
[Exclusion] an {$identifier_type} Unicode codepoint
[Technical] a {$identifier_type} Unicode codepoint
[Limited_Use] a {$identifier_type} Unicode codepoint
[Not_NFKC] a {$identifier_type} Unicode codepoint
[Exclusion] a Unicode codepoint that is no longer used
[Technical] a Unicode codepoint that has specialized usage
[Limited_Use] a Unicode codepoint that is in limited use
[Not_NFKC] a Unicode codepoint that is not used in normalized strings
*[other] an uncommon Unicode codepoint
}
*[other] { $identifier_type ->
[Exclusion] {$identifier_type} Unicode codepoints
[Technical] {$identifier_type} Unicode codepoints
[Limited_Use] {$identifier_type} Unicode codepoints
[Not_NFKC] {$identifier_type} Unicode codepoints
[Exclusion] {$codepoints_len} Unicode codepoints that are no longer used
[Technical] {$codepoints_len} Unicode codepoints that have specialized usage
[Limited_Use] {$codepoints_len} Unicode codepoints that are in limited use
[Not_NFKC] {$codepoints_len} Unicode codepoints that are not used in normalized strings
*[other] uncommon Unicode codepoints
}
}: {$codepoints}
.note = {$codepoints_len ->
[one] { $identifier_type ->
[Exclusion] this character is included in the {$identifier_type} Unicode general security profile
[Technical] this character is included in the {$identifier_type} Unicode general security profile
[Limited_Use] this character is included in the {$identifier_type} Unicode general security profile
[Not_NFKC] this character is included in the {$identifier_type} Unicode general security profile
*[other] this Unicode codepoint is uncommon
}
*[other] { $identifier_type ->
[Exclusion] these characters are included in the {$identifier_type} Unicode general security profile
[Technical] these characters are included in the {$identifier_type} Unicode general security profile
[Limited_Use] these characters are included in the {$identifier_type} Unicode general security profile
[Not_NFKC] these characters are included in the {$identifier_type} Unicode general security profile
*[other] these Unicode codepoints are uncommon
}
}
lint_ignored_unless_crate_specified = {$level}({$name}) is ignored unless specified at crate level
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_lint/src/lints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1086,6 +1086,7 @@ pub struct IdentifierNonAsciiChar;

#[derive(LintDiagnostic)]
#[diag(lint_identifier_uncommon_codepoints)]
#[note]
pub struct IdentifierUncommonCodepoints {
pub codepoints: Vec<char>,
pub codepoints_len: usize,
Expand Down
1 change: 1 addition & 0 deletions tests/ui/lexer/lex-emoji-identifiers.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ warning: identifier contains an uncommon Unicode codepoint: '\u{fe0f}'
LL | let key1️⃣ = "keycap sequence";
| ^^^^
|
= note: this Unicode codepoint is uncommon
= note: `#[warn(uncommon_codepoints)]` on by default

error: aborting due to 7 previous errors; 1 warning emitted
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#![deny(uncommon_codepoints)]

const µ: f64 = 0.000001; //~ ERROR identifier contains a Not_NFKC Unicode codepoint: 'µ'
const µ: f64 = 0.000001; //~ identifier contains a Unicode codepoint that is not used in normalized strings: 'µ'
//~| WARNING should have an upper case name

fn dijkstra() {}
//~^ ERROR identifier contains a Not_NFKC Unicode codepoint: 'ij'
//~^ ERROR identifier contains a Unicode codepoint that is not used in normalized strings: 'ij'

fn main() {
let ㇻㇲㇳ = "rust"; //~ ERROR identifier contains uncommon Unicode codepoints
Expand Down
Original file line number Diff line number Diff line change
@@ -1,26 +1,31 @@
error: identifier contains a Not_NFKC Unicode codepoint: 'µ'
error: identifier contains a Unicode codepoint that is not used in normalized strings: 'µ'
--> $DIR/lint-uncommon-codepoints.rs:3:7
|
LL | const µ: f64 = 0.000001;
| ^
|
= note: this character is included in the Not_NFKC Unicode general security profile
note: the lint level is defined here
--> $DIR/lint-uncommon-codepoints.rs:1:9
|
LL | #![deny(uncommon_codepoints)]
| ^^^^^^^^^^^^^^^^^^^

error: identifier contains a Not_NFKC Unicode codepoint: 'ij'
error: identifier contains a Unicode codepoint that is not used in normalized strings: 'ij'
--> $DIR/lint-uncommon-codepoints.rs:6:4
|
LL | fn dijkstra() {}
| ^^^^^^^
|
= note: this character is included in the Not_NFKC Unicode general security profile

error: identifier contains uncommon Unicode codepoints: 'ㇻ', 'ㇲ', and 'ㇳ'
--> $DIR/lint-uncommon-codepoints.rs:10:9
|
LL | let ㇻㇲㇳ = "rust";
| ^^^^^^
|
= note: these Unicode codepoints are uncommon

warning: constant `µ` should have an upper case name
--> $DIR/lint-uncommon-codepoints.rs:3:7
Expand Down

0 comments on commit 2f6e822

Please sign in to comment.