forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#124283 - surechen:fix_123558, r=estebank Note for E0599 if shadowed bindings has the method. implement rust-lang#123558 Use a visitor to find earlier shadowed bingings which has the method. r? ``@estebank``
- Loading branch information
Showing
7 changed files
with
249 additions
and
6 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
7 changes: 7 additions & 0 deletions
7
tests/ui/methods/issues/account-for-shadowed-bindings-issue-123558.rs
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,7 @@ | ||
fn main() { | ||
let x = Some(3); | ||
let y = vec![1, 2]; | ||
if let Some(y) = x { | ||
y.push(y); //~ ERROR E0599 | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
tests/ui/methods/issues/account-for-shadowed-bindings-issue-123558.stderr
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,17 @@ | ||
error[E0599]: no method named `push` found for type `{integer}` in the current scope | ||
--> $DIR/account-for-shadowed-bindings-issue-123558.rs:5:11 | ||
| | ||
LL | y.push(y); | ||
| ^^^^ method not found in `{integer}` | ||
| | ||
note: there's an earlier shadowed binding `y` of type `Vec<{integer}>` that has method `push` available | ||
--> $DIR/account-for-shadowed-bindings-issue-123558.rs:3:9 | ||
| | ||
LL | let y = vec![1, 2]; | ||
| ^ `y` of type `Vec<{integer}>` that has method `push` defined earlier here | ||
LL | if let Some(y) = x { | ||
| - earlier `y` shadowed here with type `{integer}` | ||
|
||
error: aborting due to 1 previous error | ||
|
||
For more information about this error, try `rustc --explain E0599`. |