about summary refs log tree commit diff
path: root/compiler
diff options
context:
space:
mode:
authorHTGAzureX1212. <39023054+HTGAzureX1212@users.noreply.github.com>2024-01-23 21:16:24 +0800
committerHTGAzureX1212. <39023054+HTGAzureX1212@users.noreply.github.com>2024-01-23 21:16:24 +0800
commit3a07333a8aa873fcb75d50541f7f209e2a04f80f (patch)
tree6b6149bc30d51f004f17a187378289195c6c1b92 /compiler
parentf3682a1304200d554d2d36abf21376861b9ae14a (diff)
downloadrust-3a07333a8aa873fcb75d50541f7f209e2a04f80f.tar.gz
rust-3a07333a8aa873fcb75d50541f7f209e2a04f80f.zip
address requested changes
Diffstat (limited to 'compiler')
-rw-r--r--compiler/rustc_lint/messages.ftl5
-rw-r--r--compiler/rustc_lint/src/lints.rs1
-rw-r--r--compiler/rustc_lint/src/non_ascii_idents.rs13
3 files changed, 12 insertions, 7 deletions
diff --git a/compiler/rustc_lint/messages.ftl b/compiler/rustc_lint/messages.ftl
index ac456c69c57..b4506990d4f 100644
--- a/compiler/rustc_lint/messages.ftl
+++ b/compiler/rustc_lint/messages.ftl
@@ -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
 
diff --git a/compiler/rustc_lint/src/lints.rs b/compiler/rustc_lint/src/lints.rs
index 7d63fad3044..e19bb1cb62f 100644
--- a/compiler/rustc_lint/src/lints.rs
+++ b/compiler/rustc_lint/src/lints.rs
@@ -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)]
diff --git a/compiler/rustc_lint/src/non_ascii_idents.rs b/compiler/rustc_lint/src/non_ascii_idents.rs
index ec11f7a6130..f78b32ce5e7 100644
--- a/compiler/rustc_lint/src/non_ascii_idents.rs
+++ b/compiler/rustc_lint/src/non_ascii_idents.rs
@@ -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 },
                 );
             }
         }