rust/tests/ui/pattern/usefulness/conflicting_bindings.rs

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

25 lines
839 B
Rust
Raw Normal View History

2023-10-28 23:11:52 -05:00
#![feature(if_let_guard, let_chains)]
fn main() {
let mut x = Some(String::new());
let ref mut y @ ref mut z = x;
//~^ ERROR: mutable more than once
let Some(ref mut y @ ref mut z) = x else { return };
//~^ ERROR: mutable more than once
if let Some(ref mut y @ ref mut z) = x {}
//~^ ERROR: mutable more than once
if let Some(ref mut y @ ref mut z) = x && true {}
2023-10-28 23:15:36 -05:00
//~^ ERROR: mutable more than once
2023-10-28 23:11:52 -05:00
while let Some(ref mut y @ ref mut z) = x {}
//~^ ERROR: mutable more than once
while let Some(ref mut y @ ref mut z) = x && true {}
2023-10-28 23:15:36 -05:00
//~^ ERROR: mutable more than once
2023-10-28 23:11:52 -05:00
match x {
ref mut y @ ref mut z => {} //~ ERROR: mutable more than once
}
match () {
() if let Some(ref mut y @ ref mut z) = x => {} //~ ERROR: mutable more than once
_ => {}
}
}