File tree Expand file tree Collapse file tree 3 files changed +18
-1
lines changed Expand file tree Collapse file tree 3 files changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -188,7 +188,11 @@ fn find_best_match_for_name_impl(
188188 return Some ( * c) ;
189189 }
190190
191- let mut dist = dist. unwrap_or_else ( || cmp:: max ( lookup. len ( ) , 3 ) / 3 ) ;
191+ // `fn edit_distance()` use `chars()` to calculate edit distance, so we must
192+ // also use `chars()` (and not `str::len()`) to calculate length here.
193+ let lookup_len = lookup. chars ( ) . count ( ) ;
194+
195+ let mut dist = dist. unwrap_or_else ( || cmp:: max ( lookup_len, 3 ) / 3 ) ;
192196 let mut best = None ;
193197 // store the candidates with the same distance, only for `use_substring_score` current.
194198 let mut next_candidates = vec ! [ ] ;
Original file line number Diff line number Diff line change 1+ fn main ( ) {
2+ // There shall be no suggestions here. In particular not `Ok`.
3+ let _ = 读文; //~ ERROR cannot find value `读文` in this scope
4+ }
Original file line number Diff line number Diff line change 1+ error[E0425]: cannot find value `读文` in this scope
2+ --> $DIR/non_ascii_ident.rs:3:13
3+ |
4+ LL | let _ = 读文;
5+ | ^^^^ not found in this scope
6+
7+ error: aborting due to 1 previous error
8+
9+ For more information about this error, try `rustc --explain E0425`.
You can’t perform that action at this time.
0 commit comments