2024-03-09 03:29:52 +01:00
|
|
|
#![feature(deref_patterns)]
|
|
|
|
|
#![allow(incomplete_features)]
|
|
|
|
|
|
|
|
|
|
use std::rc::Rc;
|
|
|
|
|
|
|
|
|
|
struct Struct;
|
|
|
|
|
|
2025-03-16 18:21:00 -07:00
|
|
|
fn cant_move_out_vec(b: Vec<Struct>) -> Struct {
|
2024-03-09 03:29:52 +01:00
|
|
|
match b {
|
2025-03-16 18:21:00 -07:00
|
|
|
//~^ ERROR: cannot move out of type `[Struct]`, a non-copy slice
|
|
|
|
|
deref!([x]) => x,
|
|
|
|
|
_ => panic!(),
|
2024-03-09 03:29:52 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn cant_move_out_rc(rc: Rc<Struct>) -> Struct {
|
|
|
|
|
match rc {
|
|
|
|
|
//~^ ERROR: cannot move out of a shared reference
|
|
|
|
|
deref!(x) => x,
|
|
|
|
|
_ => unreachable!(),
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2025-03-16 18:21:00 -07:00
|
|
|
fn cant_move_out_vec_implicit(b: Vec<Struct>) -> Struct {
|
2025-03-08 21:07:11 -08:00
|
|
|
match b {
|
2025-03-16 18:21:00 -07:00
|
|
|
//~^ ERROR: cannot move out of type `[Struct]`, a non-copy slice
|
|
|
|
|
[x] => x,
|
|
|
|
|
_ => panic!(),
|
2025-03-08 21:07:11 -08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2025-03-16 18:21:00 -07:00
|
|
|
struct Container(Struct);
|
|
|
|
|
|
2025-03-08 21:07:11 -08:00
|
|
|
fn cant_move_out_rc_implicit(rc: Rc<Container>) -> Struct {
|
|
|
|
|
match rc {
|
|
|
|
|
//~^ ERROR: cannot move out of a shared reference
|
|
|
|
|
Container(x) => x,
|
|
|
|
|
_ => unreachable!(),
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-03-09 03:29:52 +01:00
|
|
|
fn main() {}
|