about summary refs log tree commit diff
diff options
context:
space:
mode:
authorJacob Pratt <jacob@jhpratt.dev>2025-08-10 15:43:55 -0400
committerGitHub <noreply@github.com>2025-08-10 15:43:55 -0400
commit733568ac7d66ff07bb7e6ada6a447e7f020fb3a2 (patch)
treea5435a415bfd6c6608a11ba1070909bb7406d85c
parentadf522cefb725ec14ed52d8304c6fb7f0f1f5041 (diff)
parentcf1a1b7b76a937afae997594d931b64956e74a4f (diff)
downloadrust-733568ac7d66ff07bb7e6ada6a447e7f020fb3a2.tar.gz
rust-733568ac7d66ff07bb7e6ada6a447e7f020fb3a2.zip
Rollup merge of #145152 - xizheyin:detect-confusion-type, r=lqd
Use `eq_ignore_ascii_case` to avoid heap alloc in `detect_confuse_type`

A small optimization has been made, using `to_ascii_lowercase()` instead of `to_lowercase().to_string()`.

r? compiler
-rw-r--r--compiler/rustc_errors/src/emitter.rs2
1 files changed, 1 insertions, 1 deletions
diff --git a/compiler/rustc_errors/src/emitter.rs b/compiler/rustc_errors/src/emitter.rs
index 0c839f94f7f..97c47fa9b9a 100644
--- a/compiler/rustc_errors/src/emitter.rs
+++ b/compiler/rustc_errors/src/emitter.rs
@@ -3546,7 +3546,7 @@ pub fn detect_confusion_type(sm: &SourceMap, suggested: &str, sp: Span) -> Confu
 
         for (f, s) in iter::zip(found.chars(), suggested.chars()) {
             if f != s {
-                if f.to_lowercase().to_string() == s.to_lowercase().to_string() {
+                if f.eq_ignore_ascii_case(&s) {
                     // Check for case differences (any character that differs only in case)
                     if ascii_confusables.contains(&f) || ascii_confusables.contains(&s) {
                         has_case_diff = true;