1 // Suggest not mutably borrowing a mutable reference
2 #![crate_type = "rlib"]
4 pub fn f(b: &mut i32) {
5 //~^ NOTE the binding is already a mutable borrow
6 //~| NOTE the binding is already a mutable borrow
8 //~^ ERROR cannot borrow
9 //~| NOTE cannot borrow as mutable
10 //~| HELP try removing `&mut` here
12 //~^ ERROR cannot borrow
13 //~| NOTE cannot borrow as mutable
14 //~| HELP try removing `&mut` here
17 pub fn g(b: &mut i32) { //~ NOTE the binding is already a mutable borrow
19 //~^ ERROR cannot borrow
20 //~| NOTE cannot borrow as mutable
21 //~| HELP try removing `&mut` here
24 pub fn h(_: &mut i32) {}
30 impl Foo for &mut String {
34 pub fn baz(f: &mut String) { //~ HELP consider making the binding mutable
35 f.bar(); //~ ERROR cannot borrow `f` as mutable, as it is not declared as mutable
36 //~^ NOTE cannot borrow as mutable