mirror of
https://github.com/rust-lang/rust.git
synced 2025-06-04 19:29:07 +00:00
address requested changes
This commit is contained in:
parent
f3682a1304
commit
3a07333a8a
@ -240,7 +240,10 @@ lint_hidden_unicode_codepoints = unicode codepoint changing visible direction of
|
|||||||
|
|
||||||
lint_identifier_non_ascii_char = identifier contains non-ASCII characters
|
lint_identifier_non_ascii_char = identifier contains non-ASCII characters
|
||||||
|
|
||||||
lint_identifier_uncommon_codepoints = identifier contains uncommon Unicode codepoints: {$codepoints}
|
lint_identifier_uncommon_codepoints = identifier contains {$codepoints_len ->
|
||||||
|
[one] an uncommon Unicode codepoint
|
||||||
|
*[other] uncommon Unicode codepoints
|
||||||
|
}: {$codepoints}
|
||||||
|
|
||||||
lint_ignored_unless_crate_specified = {$level}({$name}) is ignored unless specified at crate level
|
lint_ignored_unless_crate_specified = {$level}({$name}) is ignored unless specified at crate level
|
||||||
|
|
||||||
|
@ -1109,6 +1109,7 @@ pub struct IdentifierNonAsciiChar;
|
|||||||
#[diag(lint_identifier_uncommon_codepoints)]
|
#[diag(lint_identifier_uncommon_codepoints)]
|
||||||
pub struct IdentifierUncommonCodepoints {
|
pub struct IdentifierUncommonCodepoints {
|
||||||
pub codepoints: Vec<char>,
|
pub codepoints: Vec<char>,
|
||||||
|
pub codepoints_len: usize,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(LintDiagnostic)]
|
#[derive(LintDiagnostic)]
|
||||||
|
@ -190,15 +190,16 @@ impl EarlyLintPass for NonAsciiIdents {
|
|||||||
if check_uncommon_codepoints
|
if check_uncommon_codepoints
|
||||||
&& !symbol_str.chars().all(GeneralSecurityProfile::identifier_allowed)
|
&& !symbol_str.chars().all(GeneralSecurityProfile::identifier_allowed)
|
||||||
{
|
{
|
||||||
|
let codepoints: Vec<_> = symbol_str
|
||||||
|
.chars()
|
||||||
|
.filter(|c| !GeneralSecurityProfile::identifier_allowed(*c))
|
||||||
|
.collect();
|
||||||
|
let codepoints_len = codepoints.len();
|
||||||
|
|
||||||
cx.emit_span_lint(
|
cx.emit_span_lint(
|
||||||
UNCOMMON_CODEPOINTS,
|
UNCOMMON_CODEPOINTS,
|
||||||
sp,
|
sp,
|
||||||
IdentifierUncommonCodepoints {
|
IdentifierUncommonCodepoints { codepoints, codepoints_len },
|
||||||
codepoints: symbol_str
|
|
||||||
.chars()
|
|
||||||
.filter(|c| !GeneralSecurityProfile::identifier_allowed(*c))
|
|
||||||
.collect(),
|
|
||||||
},
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,7 @@ fn invalid_emoji_usages() {
|
|||||||
let wireless🛜 = "basic emoji"; //~ ERROR: identifiers cannot contain emoji
|
let wireless🛜 = "basic emoji"; //~ ERROR: identifiers cannot contain emoji
|
||||||
// FIXME
|
// FIXME
|
||||||
let key1️⃣ = "keycap sequence"; //~ ERROR: unknown start of token
|
let key1️⃣ = "keycap sequence"; //~ ERROR: unknown start of token
|
||||||
//~^ WARN: identifier contains uncommon Unicode codepoints
|
//~^ WARN: identifier contains an uncommon Unicode codepoint
|
||||||
let flag🇺🇳 = "flag sequence"; //~ ERROR: identifiers cannot contain emoji
|
let flag🇺🇳 = "flag sequence"; //~ ERROR: identifiers cannot contain emoji
|
||||||
let wales🏴 = "tag sequence"; //~ ERROR: identifiers cannot contain emoji
|
let wales🏴 = "tag sequence"; //~ ERROR: identifiers cannot contain emoji
|
||||||
let folded🙏🏿 = "modifier sequence"; //~ ERROR: identifiers cannot contain emoji
|
let folded🙏🏿 = "modifier sequence"; //~ ERROR: identifiers cannot contain emoji
|
||||||
|
@ -40,7 +40,7 @@ error: identifiers cannot contain emoji: `folded🙏🏿`
|
|||||||
LL | let folded🙏🏿 = "modifier sequence";
|
LL | let folded🙏🏿 = "modifier sequence";
|
||||||
| ^^^^^^^^^^
|
| ^^^^^^^^^^
|
||||||
|
|
||||||
warning: identifier contains uncommon Unicode codepoints: '\u{fe0f}'
|
warning: identifier contains an uncommon Unicode codepoint: '\u{fe0f}'
|
||||||
--> $DIR/lex-emoji-identifiers.rs:6:9
|
--> $DIR/lex-emoji-identifiers.rs:6:9
|
||||||
|
|
|
|
||||||
LL | let key1️⃣ = "keycap sequence";
|
LL | let key1️⃣ = "keycap sequence";
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
#![deny(uncommon_codepoints)]
|
#![deny(uncommon_codepoints)]
|
||||||
|
|
||||||
const µ: f64 = 0.000001; //~ ERROR identifier contains uncommon Unicode codepoints
|
const µ: f64 = 0.000001; //~ ERROR identifier contains an uncommon Unicode codepoint
|
||||||
//~| WARNING should have an upper case name
|
//~| WARNING should have an upper case name
|
||||||
|
|
||||||
fn dijkstra() {} //~ ERROR identifier contains uncommon Unicode codepoints
|
fn dijkstra() {} //~ ERROR identifier contains an uncommon Unicode codepoint
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let ㇻㇲㇳ = "rust"; //~ ERROR identifier contains uncommon Unicode codepoints
|
let ㇻㇲㇳ = "rust"; //~ ERROR identifier contains uncommon Unicode codepoints
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
error: identifier contains uncommon Unicode codepoints: 'µ'
|
error: identifier contains an uncommon Unicode codepoint: 'µ'
|
||||||
--> $DIR/lint-uncommon-codepoints.rs:3:7
|
--> $DIR/lint-uncommon-codepoints.rs:3:7
|
||||||
|
|
|
|
||||||
LL | const µ: f64 = 0.000001;
|
LL | const µ: f64 = 0.000001;
|
||||||
@ -10,7 +10,7 @@ note: the lint level is defined here
|
|||||||
LL | #![deny(uncommon_codepoints)]
|
LL | #![deny(uncommon_codepoints)]
|
||||||
| ^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
error: identifier contains uncommon Unicode codepoints: 'ij'
|
error: identifier contains an uncommon Unicode codepoint: 'ij'
|
||||||
--> $DIR/lint-uncommon-codepoints.rs:6:4
|
--> $DIR/lint-uncommon-codepoints.rs:6:4
|
||||||
|
|
|
|
||||||
LL | fn dijkstra() {}
|
LL | fn dijkstra() {}
|
||||||
|
Loading…
Reference in New Issue
Block a user