2013-04-17 21:36:59 -05:00
|
|
|
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
|
|
|
|
// file at the top-level directory of this distribution and at
|
|
|
|
// http://rust-lang.org/COPYRIGHT.
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
|
|
|
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
|
|
|
// option. This file may not be copied, modified, or distributed
|
|
|
|
// except according to those terms.
|
|
|
|
|
|
|
|
// Test that certain pattern-match type errors are non-fatal
|
|
|
|
|
|
|
|
enum A {
|
2015-01-08 04:54:35 -06:00
|
|
|
B(isize, isize),
|
|
|
|
C(isize, isize, isize),
|
2013-04-17 21:36:59 -05:00
|
|
|
D
|
|
|
|
}
|
|
|
|
|
|
|
|
struct S {
|
2015-01-08 04:54:35 -06:00
|
|
|
a: isize
|
2013-04-17 21:36:59 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
fn f(_c: char) {}
|
|
|
|
|
|
|
|
fn main() {
|
2014-11-06 02:05:53 -06:00
|
|
|
match A::B(1, 2) {
|
|
|
|
A::B(_, _, _) => (), //~ ERROR this pattern has 3 fields, but
|
2016-03-06 06:54:44 -06:00
|
|
|
A::D(_) => (), //~ ERROR `A::D` does not name a tuple variant or a tuple struct
|
2013-04-17 21:36:59 -05:00
|
|
|
_ => ()
|
|
|
|
}
|
|
|
|
match 'c' {
|
2014-10-20 20:40:15 -05:00
|
|
|
S { .. } => (),
|
2015-01-12 00:01:44 -06:00
|
|
|
//~^ ERROR mismatched types
|
2016-04-20 13:42:13 -05:00
|
|
|
//~| expected type `char`
|
|
|
|
//~| found type `S`
|
|
|
|
//~| expected char, found struct `S`
|
2013-08-12 18:44:07 -05:00
|
|
|
|
2013-04-17 21:36:59 -05:00
|
|
|
_ => ()
|
|
|
|
}
|
2015-01-12 00:01:44 -06:00
|
|
|
f(true);
|
|
|
|
//~^ ERROR mismatched types
|
2016-04-20 13:42:13 -05:00
|
|
|
//~| expected char, found bool
|
2016-04-16 21:37:15 -05:00
|
|
|
|
|
|
|
match () {
|
|
|
|
E::V => {} //~ ERROR failed to resolve. Use of undeclared type or module `E`
|
|
|
|
}
|
2013-08-12 18:44:07 -05:00
|
|
|
}
|