diff --git a/src/test/compile-fail/alt-pattern-field-mismatch-2.rs b/src/test/compile-fail/alt-pattern-field-mismatch-2.rs new file mode 100644 index 00000000000..75e0763e4a6 --- /dev/null +++ b/src/test/compile-fail/alt-pattern-field-mismatch-2.rs @@ -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 + } + } +} diff --git a/src/test/compile-fail/alt-pattern-field-mismatch.rs b/src/test/compile-fail/alt-pattern-field-mismatch.rs new file mode 100644 index 00000000000..086267a85b3 --- /dev/null +++ b/src/test/compile-fail/alt-pattern-field-mismatch.rs @@ -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 { } + } + } +}