Check type when struct is matched against enum-like pattern
Previously check always succeeded because struct type was derived from the matched expression, not the matched pattern.
This commit is contained in:
parent
67ee95e943
commit
a29023e9b2
3 changed files with 23 additions and 3 deletions
11
src/test/compile-fail/match-struct.rs
Normal file
11
src/test/compile-fail/match-struct.rs
Normal file
|
@ -0,0 +1,11 @@
|
|||
// error-pattern: mismatched types
|
||||
|
||||
struct S { a: int }
|
||||
enum E { C(int) }
|
||||
|
||||
fn main() {
|
||||
match S { a: 1 } {
|
||||
C(_) => (),
|
||||
_ => ()
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue