]> git.lizzy.rs Git - rust.git/blob - src/test/ui/augmented-assignments.rs
Rollup merge of #106008 - uweigand:s390x-lintgroup-order, r=Nilstrieb
[rust.git] / src / test / ui / augmented-assignments.rs
1 use std::ops::AddAssign;
2
3 struct Int(i32);
4
5 impl AddAssign for Int {
6     fn add_assign(&mut self, _: Int) {
7         unimplemented!()
8     }
9 }
10
11 fn main() {
12     let mut x = Int(1);
13     x
14     //~^ NOTE borrow of `x` occurs here
15     +=
16     x;
17     //~^ ERROR cannot move out of `x` because it is borrowed
18     //~| move out of `x` occurs here
19
20     let y = Int(2);
21     //~^ HELP consider changing this to be mutable
22     //~| SUGGESTION mut y
23     y   //~ ERROR cannot borrow `y` as mutable, as it is not declared as mutable
24         //~| cannot borrow as mutable
25     +=
26     Int(1);
27 }