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