2019-09-07 17:55:38 -05:00
|
|
|
// Test the "defined here" and "not covered" diagnostic hints.
|
|
|
|
// We also make sure that references are peeled off from the scrutinee type
|
|
|
|
// so that the diagnostics work better with default binding modes.
|
|
|
|
|
|
|
|
#[derive(Clone)]
|
|
|
|
enum E {
|
2021-12-15 23:06:44 -06:00
|
|
|
//~^ NOTE
|
|
|
|
//~| NOTE
|
|
|
|
//~| NOTE
|
|
|
|
//~| NOTE
|
|
|
|
//~| NOTE
|
|
|
|
//~| NOTE
|
2019-09-07 17:55:38 -05:00
|
|
|
A,
|
|
|
|
B,
|
2021-12-15 23:06:44 -06:00
|
|
|
//~^ NOTE `E` defined here
|
|
|
|
//~| NOTE `E` defined here
|
|
|
|
//~| NOTE `E` defined here
|
|
|
|
//~| NOTE not covered
|
|
|
|
//~| NOTE not covered
|
|
|
|
//~| NOTE not covered
|
|
|
|
//~| NOTE not covered
|
|
|
|
//~| NOTE not covered
|
|
|
|
//~| NOTE not covered
|
2019-09-07 17:55:38 -05:00
|
|
|
C
|
|
|
|
//~^ not covered
|
|
|
|
//~| not covered
|
|
|
|
//~| not covered
|
2019-09-09 09:44:06 -05:00
|
|
|
//~| not covered
|
|
|
|
//~| not covered
|
|
|
|
//~| not covered
|
2019-09-07 17:55:38 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
fn by_val(e: E) {
|
|
|
|
let e1 = e.clone();
|
2022-09-02 22:01:35 -05:00
|
|
|
match e1 { //~ ERROR non-exhaustive patterns: `E::B` and `E::C` not covered
|
|
|
|
//~^ NOTE patterns `E::B` and `E::C` not covered
|
2021-12-15 23:06:44 -06:00
|
|
|
//~| NOTE the matched value is of type `E`
|
2019-09-07 17:55:38 -05:00
|
|
|
E::A => {}
|
|
|
|
}
|
|
|
|
|
2022-12-23 14:02:23 -06:00
|
|
|
let E::A = e;
|
|
|
|
//~^ ERROR refutable pattern in local binding
|
|
|
|
//~| patterns `E::B` and `E::C` not covered
|
2021-12-15 23:06:44 -06:00
|
|
|
//~| NOTE `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with
|
|
|
|
//~| NOTE for more information, visit https://doc.rust-lang.org/book/ch18-02-refutability.html
|
|
|
|
//~| NOTE the matched value is of type `E`
|
2019-09-07 17:55:38 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
fn by_ref_once(e: &E) {
|
2022-12-23 14:02:23 -06:00
|
|
|
match e {
|
|
|
|
//~^ ERROR non-exhaustive patterns
|
|
|
|
//~| patterns `&E::B` and `&E::C` not covered
|
2021-12-15 23:06:44 -06:00
|
|
|
//~| NOTE the matched value is of type `&E`
|
2019-09-07 17:55:38 -05:00
|
|
|
E::A => {}
|
|
|
|
}
|
|
|
|
|
2022-12-23 14:02:23 -06:00
|
|
|
let E::A = e;
|
|
|
|
//~^ ERROR refutable pattern in local binding
|
|
|
|
//~| patterns `&E::B` and `&E::C` not covered
|
2021-12-15 23:06:44 -06:00
|
|
|
//~| NOTE `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with
|
|
|
|
//~| NOTE for more information, visit https://doc.rust-lang.org/book/ch18-02-refutability.html
|
|
|
|
//~| NOTE the matched value is of type `&E`
|
2019-09-07 17:55:38 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
fn by_ref_thrice(e: & &mut &E) {
|
2022-12-23 14:02:23 -06:00
|
|
|
match e {
|
|
|
|
//~^ ERROR non-exhaustive patterns
|
|
|
|
//~| patterns `&&mut &E::B` and `&&mut &E::C` not covered
|
2021-12-15 23:06:44 -06:00
|
|
|
//~| NOTE the matched value is of type `&&mut &E`
|
2019-09-07 17:55:38 -05:00
|
|
|
E::A => {}
|
|
|
|
}
|
|
|
|
|
2019-09-09 09:44:06 -05:00
|
|
|
let E::A = e;
|
2022-12-23 14:02:23 -06:00
|
|
|
//~^ ERROR refutable pattern in local binding
|
|
|
|
//~| patterns `&&mut &E::B` and `&&mut &E::C` not covered
|
2021-12-15 23:06:44 -06:00
|
|
|
//~| NOTE `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with
|
|
|
|
//~| NOTE for more information, visit https://doc.rust-lang.org/book/ch18-02-refutability.html
|
|
|
|
//~| NOTE the matched value is of type `&&mut &E`
|
2019-09-07 17:55:38 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
enum Opt {
|
2021-12-15 23:06:44 -06:00
|
|
|
//~^ NOTE
|
|
|
|
//~| NOTE
|
2019-09-07 17:55:38 -05:00
|
|
|
Some(u8),
|
|
|
|
None,
|
2021-12-15 23:06:44 -06:00
|
|
|
//~^ NOTE `Opt` defined here
|
|
|
|
//~| NOTE not covered
|
|
|
|
//~| NOTE not covered
|
2019-09-07 17:55:38 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
fn ref_pat(e: Opt) {
|
2022-12-23 14:02:23 -06:00
|
|
|
match e {
|
|
|
|
//~^ ERROR non-exhaustive patterns
|
|
|
|
//~| pattern `Opt::None` not covered
|
2021-12-15 23:06:44 -06:00
|
|
|
//~| NOTE the matched value is of type `Opt`
|
2019-09-07 17:55:38 -05:00
|
|
|
Opt::Some(ref _x) => {}
|
|
|
|
}
|
|
|
|
|
2022-12-23 14:02:23 -06:00
|
|
|
let Opt::Some(ref _x) = e;
|
|
|
|
//~^ ERROR refutable pattern in local binding
|
|
|
|
//~| NOTE the matched value is of type `Opt`
|
2022-09-02 22:01:35 -05:00
|
|
|
//~| NOTE pattern `Opt::None` not covered
|
2021-12-15 23:06:44 -06:00
|
|
|
//~| NOTE `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with
|
|
|
|
//~| NOTE for more information, visit https://doc.rust-lang.org/book/ch18-02-refutability.html
|
2019-09-07 17:55:38 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {}
|