-
Notifications
You must be signed in to change notification settings - Fork 13.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add suggestions for misspelled method names
Use the syntax::util::lev_distance module to provide suggestions when a named method cannot be found. Part of #30197
- Loading branch information
Thomas Jespersen
committed
Sep 21, 2017
1 parent
ef227f5
commit 09defbc
Showing
6 changed files
with
145 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT | ||
// file at the top-level directory of this distribution and at | ||
// http://rust-lang.org/COPYRIGHT. | ||
// | ||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or | ||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license | ||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your | ||
// option. This file may not be copied, modified, or distributed | ||
// except according to those terms. | ||
|
||
struct Foo; | ||
|
||
impl Foo { | ||
fn bar(self) {} | ||
fn baz(&self, x: f64) {} | ||
} | ||
|
||
trait FooT { | ||
fn bag(&self); | ||
} | ||
|
||
impl FooT for Foo { | ||
fn bag(&self) {} | ||
} | ||
|
||
fn main() { | ||
let f = Foo; | ||
f.bat(1.0); | ||
|
||
let s = "foo".to_string(); | ||
let _ = s.is_emtpy(); | ||
|
||
// Generates a warning, both for count_ones and count_zeros | ||
let _ = 63u32.count_eos(); | ||
let _ = 63u32.count_o(); // Does not generate a warning | ||
|
||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
error[E0599]: no method named `bat` found for type `Foo` in the current scope | ||
--> $DIR/suggest-methods.rs:28:7 | ||
| | ||
28 | f.bat(1.0); | ||
| ^^^ | ||
| | ||
= help: did you mean `bar`? | ||
= help: did you mean `baz`? | ||
|
||
error[E0599]: no method named `is_emtpy` found for type `std::string::String` in the current scope | ||
--> $DIR/suggest-methods.rs:31:15 | ||
| | ||
31 | let _ = s.is_emtpy(); | ||
| ^^^^^^^^ | ||
| | ||
= help: did you mean `is_empty`? | ||
|
||
error[E0599]: no method named `count_eos` found for type `u32` in the current scope | ||
--> $DIR/suggest-methods.rs:34:19 | ||
| | ||
34 | let _ = 63u32.count_eos(); | ||
| ^^^^^^^^^ | ||
| | ||
= help: did you mean `count_ones`? | ||
= help: did you mean `count_zeros`? | ||
|
||
error[E0599]: no method named `count_o` found for type `u32` in the current scope | ||
--> $DIR/suggest-methods.rs:35:19 | ||
| | ||
35 | let _ = 63u32.count_o(); // Does not generate a warning | ||
| ^^^^^^^ | ||
|
||
error: aborting due to 4 previous errors | ||
|