forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ensure that we don't try to access fields on a non-struct pattern typ…
…e in diagnostic Fix rust-lang#135209.
- Loading branch information
Showing
3 changed files
with
38 additions
and
1 deletion.
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
7 changes: 7 additions & 0 deletions
7
tests/ui/pattern/struct-pattern-on-non-struct-resolve-error.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 @@ | ||
// Regression test for #135209. | ||
// We ensure that we don't try to access fields on a non-struct pattern type. | ||
fn main() { | ||
if let Iterator::Item { .. } = 1 { //~ ERROR E0223 | ||
x //~ ERROR E0425 | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
tests/ui/pattern/struct-pattern-on-non-struct-resolve-error.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,28 @@ | ||
error[E0425]: cannot find value `x` in this scope | ||
--> $DIR/struct-pattern-on-non-struct-resolve-error.rs:5:9 | ||
| | ||
LL | x | ||
| ^ not found in this scope | ||
|
||
error[E0223]: ambiguous associated type | ||
--> $DIR/struct-pattern-on-non-struct-resolve-error.rs:4:12 | ||
| | ||
LL | if let Iterator::Item { .. } = 1 { | ||
| ^^^^^^^^^^^^^^ | ||
| | ||
help: use fully-qualified syntax | ||
| | ||
LL | if let <Ancestors<'_> as Iterator>::Item { .. } = 1 { | ||
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
LL | if let <Args as Iterator>::Item { .. } = 1 { | ||
| ~~~~~~~~~~~~~~~~~~~~~~~~ | ||
LL | if let <ArgsOs as Iterator>::Item { .. } = 1 { | ||
| ~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
LL | if let <CharIndices<'_> as Iterator>::Item { .. } = 1 { | ||
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
and 71 other candidates | ||
|
||
error: aborting due to 2 previous errors | ||
|
||
Some errors have detailed explanations: E0223, E0425. | ||
For more information about an error, try `rustc --explain E0223`. |