mirror of
https://github.com/rust-lang/rust.git
synced 2025-12-01 04:18:27 +00:00
In rustc it doesn't really matter what the order of the witnesses is, but I'm planning to use the witnesses for implementing the "add missing match arms" assist in rust-analyzer, and there `true` before `false` is the natural order (like `Some` before `None`), and also what the current assist does. The current order doesn't seem to be intentional; the code was created when bool ctors became their own thing, not just int ctors, but for integer, 0 before 1 is indeed the natural order.
29 lines
869 B
Rust
29 lines
869 B
Rust
//! Test non-exhaustive matches involving deref patterns.
|
|
#![feature(deref_patterns)]
|
|
#![expect(incomplete_features)]
|
|
#![deny(unreachable_patterns)]
|
|
|
|
fn main() {
|
|
match Box::new(false) {
|
|
//~^ ERROR non-exhaustive patterns: `deref!(true)` not covered
|
|
false => {}
|
|
}
|
|
|
|
match Box::new(Box::new(false)) {
|
|
//~^ ERROR non-exhaustive patterns: `deref!(deref!(false))` not covered
|
|
true => {}
|
|
}
|
|
|
|
match Box::new((true, Box::new(false))) {
|
|
//~^ ERROR non-exhaustive patterns: `deref!((true, deref!(true)))` and `deref!((false, deref!(false)))` not covered
|
|
(true, false) => {}
|
|
(false, true) => {}
|
|
}
|
|
|
|
enum T { A, B, C }
|
|
match Box::new((Box::new(T::A), Box::new(T::A))) {
|
|
//~^ ERROR non-exhaustive patterns: `deref!((deref!(T::C), _))` not covered
|
|
(T::A | T::B, T::C) => {}
|
|
}
|
|
}
|