about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--compiler/rustc_span/src/lev_distance.rs3
1 files changed, 2 insertions, 1 deletions
diff --git a/compiler/rustc_span/src/lev_distance.rs b/compiler/rustc_span/src/lev_distance.rs
index aed699e4839..6554312b8b9 100644
--- a/compiler/rustc_span/src/lev_distance.rs
+++ b/compiler/rustc_span/src/lev_distance.rs
@@ -56,6 +56,7 @@ pub fn find_best_match_for_name(
     dist: Option<usize>,
 ) -> Option<Symbol> {
     let lookup = lookup.as_str();
+    let lookup_uppercase = lookup.to_uppercase();
     let max_dist = dist.unwrap_or_else(|| cmp::max(lookup.len(), 3) / 3);
 
     // Priority of matches:
@@ -63,7 +64,7 @@ pub fn find_best_match_for_name(
     // 2. Levenshtein distance match
     // 3. Sorted word match
     if let Some(case_insensitive_match) =
-        name_vec.iter().find(|candidate| candidate.as_str().to_uppercase() == lookup.to_uppercase())
+        name_vec.iter().find(|candidate| candidate.as_str().to_uppercase() == lookup_uppercase)
     {
         return Some(*case_insensitive_match);
     }