2015-02-10 21:52:00 +00:00
|
|
|
#![feature(box_patterns)]
|
2022-07-07 02:36:10 +00:00
|
|
|
|
2015-01-07 21:35:56 +00:00
|
|
|
|
2013-04-18 02:36:59 +00:00
|
|
|
enum A { B, C }
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
match (true, false) {
|
2014-11-06 08:05:53 +00:00
|
|
|
A::B => (),
|
2016-04-20 18:42:13 +00:00
|
|
|
//~^ ERROR mismatched types
|
2023-01-03 02:00:33 +00:00
|
|
|
//~| expected `(bool, bool)`, found `A`
|
2019-11-13 22:16:56 +00:00
|
|
|
//~| expected tuple `(bool, bool)`
|
|
|
|
//~| found enum `A`
|
2013-04-18 02:36:59 +00:00
|
|
|
_ => ()
|
|
|
|
}
|
|
|
|
|
|
|
|
match (true, false) {
|
2014-02-05 22:33:10 +00:00
|
|
|
(true, false, false) => ()
|
2015-01-12 06:01:44 +00:00
|
|
|
//~^ ERROR mismatched types
|
2016-04-20 18:42:13 +00:00
|
|
|
//~| expected a tuple with 2 elements, found one with 3 elements
|
2019-11-13 22:16:56 +00:00
|
|
|
//~| expected tuple `(bool, bool)`
|
|
|
|
//~| found tuple `(_, _, _)`
|
2014-10-23 20:48:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
match (true, false) {
|
|
|
|
(true, false, false) => ()
|
2015-01-12 06:01:44 +00:00
|
|
|
//~^ ERROR mismatched types
|
2016-04-20 18:42:13 +00:00
|
|
|
//~| expected a tuple with 2 elements, found one with 3 elements
|
2019-11-13 22:16:56 +00:00
|
|
|
//~| expected tuple `(bool, bool)`
|
|
|
|
//~| found tuple `(_, _, _)`
|
2013-04-18 02:36:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
match (true, false) {
|
2014-05-06 01:56:44 +00:00
|
|
|
box (true, false) => ()
|
2015-01-12 06:01:44 +00:00
|
|
|
//~^ ERROR mismatched types
|
2019-11-13 22:16:56 +00:00
|
|
|
//~| expected tuple `(bool, bool)`
|
2020-09-02 07:40:56 +00:00
|
|
|
//~| found struct `Box<_>`
|
2013-04-18 02:36:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
match (true, false) {
|
2014-02-05 22:33:10 +00:00
|
|
|
&(true, false) => ()
|
2015-01-12 06:01:44 +00:00
|
|
|
//~^ ERROR mismatched types
|
2023-01-03 02:00:33 +00:00
|
|
|
//~| expected `(bool, bool)`, found `&_`
|
2019-11-13 22:16:56 +00:00
|
|
|
//~| expected tuple `(bool, bool)`
|
|
|
|
//~| found reference `&_`
|
2013-04-18 02:36:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-10-23 20:48:32 +00:00
|
|
|
let v = [('a', 'b') //~ ERROR expected function, found `(char, char)`
|
2013-04-18 02:36:59 +00:00
|
|
|
('c', 'd'),
|
|
|
|
('e', 'f')];
|
|
|
|
|
2015-01-31 17:20:46 +00:00
|
|
|
for &(x,y) in &v {} // should be OK
|
2013-04-18 02:36:59 +00:00
|
|
|
|
|
|
|
// Make sure none of the errors above were fatal
|
2015-01-12 06:01:44 +00:00
|
|
|
let x: char = true; //~ ERROR mismatched types
|
2019-11-15 17:37:01 +00:00
|
|
|
//~| expected `char`, found `bool`
|
2013-04-18 02:36:59 +00:00
|
|
|
}
|