Show scrutinee expr type for struct fields.
TODO: The type is wrong and will be fixed in later commits.
This commit is contained in:
parent
ab050d6a83
commit
960acb044b
3 changed files with 35 additions and 3 deletions
9
src/test/ui/pattern/pat-struct-field-expr-has-type.rs
Normal file
9
src/test/ui/pattern/pat-struct-field-expr-has-type.rs
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
struct S {
|
||||
f: u8,
|
||||
}
|
||||
|
||||
fn main() {
|
||||
match (S { f: 42 }) {
|
||||
S { f: Ok(_) } => {} //~ ERROR mismatched types
|
||||
}
|
||||
}
|
||||
14
src/test/ui/pattern/pat-struct-field-expr-has-type.stderr
Normal file
14
src/test/ui/pattern/pat-struct-field-expr-has-type.stderr
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
error[E0308]: mismatched types
|
||||
--> $DIR/pat-struct-field-expr-has-type.rs:7:16
|
||||
|
|
||||
LL | match (S { f: 42 }) {
|
||||
| ------------- this expression has type `u8`
|
||||
LL | S { f: Ok(_) } => {}
|
||||
| ^^^^^ expected `u8`, found enum `std::result::Result`
|
||||
|
|
||||
= note: expected type `u8`
|
||||
found enum `std::result::Result<_, _>`
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0308`.
|
||||
Loading…
Add table
Add a link
Reference in a new issue