mirror of
https://github.com/rust-lang/rust
synced 2024-09-15 22:50:55 +00:00
c623319a30
This handles using deref patterns to choose the correct match arm. This does not handle bindings or guards. Co-authored-by: Deadbeef <ent3rm4n@gmail.com>
36 lines
677 B
Rust
36 lines
677 B
Rust
//@ check-pass
|
|
#![feature(deref_patterns)]
|
|
#![allow(incomplete_features)]
|
|
|
|
use std::rc::Rc;
|
|
|
|
struct Struct;
|
|
|
|
fn main() {
|
|
let vec: Vec<u32> = Vec::new();
|
|
match vec {
|
|
deref!([..]) => {}
|
|
_ => {}
|
|
}
|
|
match Box::new(true) {
|
|
deref!(true) => {}
|
|
_ => {}
|
|
}
|
|
match &Box::new(true) {
|
|
deref!(true) => {}
|
|
_ => {}
|
|
}
|
|
match &Rc::new(0) {
|
|
deref!(1..) => {}
|
|
_ => {}
|
|
}
|
|
let _: &Struct = match &Rc::new(Struct) {
|
|
deref!(x) => x,
|
|
_ => unreachable!(),
|
|
};
|
|
let _: &[Struct] = match &Rc::new(vec![Struct]) {
|
|
deref!(deref!(x)) => x,
|
|
_ => unreachable!(),
|
|
};
|
|
}
|