-
Notifications
You must be signed in to change notification settings - Fork 13k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #44297 - laumann:suggest-misspelt-methods, r=arielb1
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
Showing
6 changed files
with
158 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,40 @@ | ||
// 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 for `count_zeros()`. `count_ones()` is also a close | ||
// match, but the former is closer. | ||
let _ = 63u32.count_eos(); | ||
|
||
// Does not generate a warning | ||
let _ = 63u32.count_o(); | ||
|
||
} |
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,32 @@ | ||
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`? | ||
|
||
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:35:19 | ||
| | ||
35 | let _ = 63u32.count_eos(); | ||
| ^^^^^^^^^ | ||
| | ||
= 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:38:19 | ||
| | ||
38 | let _ = 63u32.count_o(); | ||
| ^^^^^^^ | ||
|
||
error: aborting due to 4 previous errors | ||
|