rust/tests/ui/pattern/deref-patterns/cant_move_out_of_pattern.rs
Nadrieril c623319a30 Lower deref patterns to MIR
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>
2024-04-20 15:59:54 +02:00

25 lines
473 B
Rust

#![feature(deref_patterns)]
#![allow(incomplete_features)]
use std::rc::Rc;
struct Struct;
fn cant_move_out_box(b: Box<Struct>) -> Struct {
match b {
//~^ ERROR: cannot move out of a shared reference
deref!(x) => x,
_ => unreachable!(),
}
}
fn cant_move_out_rc(rc: Rc<Struct>) -> Struct {
match rc {
//~^ ERROR: cannot move out of a shared reference
deref!(x) => x,
_ => unreachable!(),
}
}
fn main() {}