File tree 2 files changed +18
-4
lines changed
2 files changed +18
-4
lines changed Original file line number Diff line number Diff line change @@ -4666,7 +4666,7 @@ pub impl Resolver {
4666
4666
}
4667
4667
}
4668
4668
4669
- fn find_best_match_for_name(@mut self, name: &str) -> Option<~str> {
4669
+ fn find_best_match_for_name(@mut self, name: &str, max_distance: uint ) -> Option<~str> {
4670
4670
let this = &mut *self;
4671
4671
4672
4672
let mut maybes: ~[~str] = ~[];
@@ -4694,6 +4694,7 @@ pub impl Resolver {
4694
4694
if vec::len(values) > 0 &&
4695
4695
values[smallest] != uint::max_value &&
4696
4696
values[smallest] < str::len(name) + 2 &&
4697
+ values[smallest] <= max_distance &&
4697
4698
maybes[smallest] != name.to_owned() {
4698
4699
4699
4700
Some(vec::swap_remove(&mut maybes, smallest))
@@ -4770,8 +4771,9 @@ pub impl Resolver {
4770
4771
wrong_name) ) ;
4771
4772
}
4772
4773
else {
4773
- match self . find_best_match_for_name( wrong_name) {
4774
-
4774
+ // limit search to 5 to reduce the number
4775
+ // of stupid suggestions
4776
+ match self . find_best_match_for_name( wrong_name, 5 ) {
4775
4777
Some ( m) => {
4776
4778
self . session. span_err( expr. span,
4777
4779
fmt ! ( "unresolved name: `%s`. \
@@ -5292,4 +5294,3 @@ pub fn resolve_crate(session: Session,
5292
5294
trait_map : trait_map
5293
5295
}
5294
5296
}
5295
-
Original file line number Diff line number Diff line change
1
+ // Copyright 2012 The Rust Project Developers. See the COPYRIGHT
2
+ // file at the top-level directory of this distribution and at
3
+ // http://rust-lang.org/COPYRIGHT.
4
+ //
5
+ // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6
+ // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7
+ // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8
+ // option. This file may not be copied, modified, or distributed
9
+ // except according to those terms.
10
+
11
+ // error-pattern: unresolved name: `foobar`.
12
+
13
+ fn main ( args : ~[ str ] ) { debug ! ( foobar) ; }
You can’t perform that action at this time.
0 commit comments