Add tests to exercise the "pattern has N field(s), but" error patterns.
This commit is contained in:
parent
abfa8164cd
commit
0fe9c0a9d1
16
src/test/compile-fail/alt-pattern-field-mismatch-2.rs
Normal file
16
src/test/compile-fail/alt-pattern-field-mismatch-2.rs
Normal file
@ -0,0 +1,16 @@
|
||||
fn main() {
|
||||
enum color {
|
||||
rgb(uint, uint, uint),
|
||||
cmyk(uint, uint, uint, uint),
|
||||
no_color,
|
||||
}
|
||||
|
||||
fn foo(c: color) {
|
||||
alt c {
|
||||
rgb(_, _, _) { }
|
||||
cmyk(_, _, _, _) { }
|
||||
no_color(_) { }
|
||||
//!^ ERROR this pattern has 1 field, but the corresponding variant has no fields
|
||||
}
|
||||
}
|
||||
}
|
16
src/test/compile-fail/alt-pattern-field-mismatch.rs
Normal file
16
src/test/compile-fail/alt-pattern-field-mismatch.rs
Normal file
@ -0,0 +1,16 @@
|
||||
fn main() {
|
||||
enum color {
|
||||
rgb(uint, uint, uint),
|
||||
cmyk(uint, uint, uint, uint),
|
||||
no_color,
|
||||
}
|
||||
|
||||
fn foo(c: color) {
|
||||
alt c {
|
||||
rgb(_, _) { }
|
||||
//!^ ERROR this pattern has 2 fields, but the corresponding variant has 3 fields
|
||||
cmyk(_, _, _, _) { }
|
||||
no_color { }
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user