]> git.lizzy.rs Git - rust.git/blob - src/test/ui/nll/issue-51191.rs
Rollup merge of #105216 - GuillaumeGomez:rm-unused-gui-test, r=notriddle
[rust.git] / src / test / ui / nll / issue-51191.rs
1 struct Struct;
2
3 impl Struct {
4     fn bar(self: &mut Self) {
5         //~^ WARN function cannot return without recursing
6         //~^^ HELP a `loop` may express intention better if this is on purpose
7         (&mut self).bar();
8         //~^ ERROR cannot borrow `self` as mutable, as it is not declared as mutable [E0596]
9         //~^^ HELP try removing `&mut` here
10     }
11
12     fn imm(self) { //~ HELP consider changing this to be mutable
13         (&mut self).bar();
14         //~^ ERROR cannot borrow `self` as mutable, as it is not declared as mutable [E0596]
15     }
16
17     fn mtbl(mut self) {
18         (&mut self).bar();
19     }
20
21     fn immref(&self) {
22         (&mut self).bar();
23         //~^ ERROR cannot borrow `self` as mutable, as it is not declared as mutable [E0596]
24         //~^^ ERROR cannot borrow data in a `&` reference as mutable [E0596]
25     }
26
27     fn mtblref(&mut self) {
28         (&mut self).bar();
29         //~^ ERROR cannot borrow `self` as mutable, as it is not declared as mutable [E0596]
30         //~^^ HELP try removing `&mut` here
31     }
32 }
33
34 fn main() {}