]> git.lizzy.rs Git - rust.git/blob - tests/ui/borrowck/issue-51117.rs
Rollup merge of #106605 - notriddle:notriddle/outdated-rustbook, r=GuillaumeGomez
[rust.git] / tests / ui / borrowck / issue-51117.rs
1 // Regression test for #51117 in borrowck interaction with match
2 // default bindings. The borrow of `*bar` created by `baz` was failing
3 // to register as a conflict with `bar.take()`.
4
5 fn main() {
6     let mut foo = Some("foo".to_string());
7     let bar = &mut foo;
8     match bar {
9         Some(baz) => {
10             bar.take(); //~ ERROR cannot borrow
11             drop(baz);
12         },
13         None => unreachable!(),
14     }
15 }