rust/tests/ui/borrowck/issue-10876.rs
2024-02-16 20:02:50 +00:00

18 lines
245 B
Rust

//@ check-pass
enum Nat {
S(Box<Nat>),
Z
}
fn test(x: &mut Nat) {
let mut p = &mut *x;
loop {
match p {
&mut Nat::Z => break,
&mut Nat::S(ref mut n) => p = &mut *n
}
}
}
fn main() {}