-
Notifications
You must be signed in to change notification settings - Fork 12.3k
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 #55156 - PramodBisht:issue/52717, r=estebank
Fixed: Multiple errors on single typo in match pattern Here we have fixed the case where we were throwing two diagnostic messages `E0026` and `E0027` for same case. Example ``` error[E0026]: variant `A::A` does not have a field named `fob` --> src/test/ui/issue-52717.rs:20:12 | 20 | A::A { fob } => { println!("{}", fob); } | ^^^ variant `A::A` does not have this field error[E0027]: pattern does not mention field `foo` --> src/test/ui/issue-52717.rs:20:5 | 20 | A::A { fob } => { println!("{}", fob); } | ^^^^^^^^^^^^ missing field `foo` error: aborting due to 2 previous errors ``` Here above we can see that both `E0026` and `E0027` are depicting same thing. So, to fix this issue, we are simply checking if for last element of `inexistent_fields` is there any value lies in `unmentioned_fields` using levenshtein algorithm, if it does then for that case we are simply deleting element from `unmentioned_fields`. More or less, now instead of showing separate message in `E0027` we are giving extra hint on `E0026` r? @estebank
- Loading branch information
Showing
5 changed files
with
56 additions
and
20 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// Copyright 2018 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. | ||
enum A { | ||
A { | ||
foo: usize, | ||
} | ||
} | ||
|
||
fn main() { | ||
let x = A::A { foo: 3 }; | ||
match x { | ||
A::A { fob } => { println!("{}", fob); } | ||
} | ||
} |
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,12 @@ | ||
error[E0026]: variant `A::A` does not have a field named `fob` | ||
--> $DIR/issue-52717.rs:19:12 | ||
| | ||
LL | A::A { fob } => { println!("{}", fob); } | ||
| ^^^ | ||
| | | ||
| variant `A::A` does not have this field | ||
| help: did you mean: `foo` | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0026`. |
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