rust/src/test/ui/augmented-assignments.rs

26 lines
501 B
Rust
Raw Normal View History

2015-09-10 19:16:57 -05:00
use std::ops::AddAssign;
struct Int(i32);
impl AddAssign for Int {
fn add_assign(&mut self, _: Int) {
unimplemented!()
}
}
fn main() {
let mut x = Int(1);
x //~ error: use of moved value: `x`
//~^ value used here after move
2015-09-10 19:16:57 -05:00
+=
x; //~ value moved here
2015-09-10 19:16:57 -05:00
let y = Int(2);
//~^ HELP make this binding mutable
//~| SUGGESTION mut y
2015-09-10 19:16:57 -05:00
y //~ error: cannot borrow immutable local variable `y` as mutable
2016-05-12 16:39:09 -07:00
//~| cannot borrow
2015-09-10 19:16:57 -05:00
+=
Int(1);
}