address requested changes
This commit is contained in:
parent
f3682a1304
commit
3a07333a8a
7 changed files with 18 additions and 13 deletions
|
@ -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_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
|
||||
|
||||
|
|
|
@ -1109,6 +1109,7 @@ pub struct IdentifierNonAsciiChar;
|
|||
#[diag(lint_identifier_uncommon_codepoints)]
|
||||
pub struct IdentifierUncommonCodepoints {
|
||||
pub codepoints: Vec<char>,
|
||||
pub codepoints_len: usize,
|
||||
}
|
||||
|
||||
#[derive(LintDiagnostic)]
|
||||
|
|
|
@ -190,15 +190,16 @@ impl EarlyLintPass for NonAsciiIdents {
|
|||
if check_uncommon_codepoints
|
||||
&& !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(
|
||||
UNCOMMON_CODEPOINTS,
|
||||
sp,
|
||||
IdentifierUncommonCodepoints {
|
||||
codepoints: symbol_str
|
||||
.chars()
|
||||
.filter(|c| !GeneralSecurityProfile::identifier_allowed(*c))
|
||||
.collect(),
|
||||
},
|
||||
IdentifierUncommonCodepoints { codepoints, codepoints_len },
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue