rust/tests/ui/borrowck/borrowck-issue-48962.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

27 lines
397 B
Rust
Raw Normal View History

struct Node {
elem: i32,
next: Option<Box<Node>>,
}
fn a() {
let mut node = Node {
elem: 5,
next: None,
};
let mut src = &mut node;
{src};
src.next = None; //~ ERROR use of moved value: `src` [E0382]
}
fn b() {
let mut src = &mut (22, 44);
{src};
src.0 = 66; //~ ERROR use of moved value: `src` [E0382]
}
fn main() {
a();
b();
}