blob: 5d776d4fca4752f7ab2506717a084c8c7833df47 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
#[derive(Copy, Clone)]
struct S;
impl S {
fn mutate(&mut self) {
}
}
fn func(arg: S) {
arg.mutate(); //~ ERROR: cannot borrow `arg` as mutable, as it is not declared as mutable
}
impl S {
fn method(&self, arg: S) {
arg.mutate(); //~ ERROR: cannot borrow `arg` as mutable, as it is not declared as mutable
}
}
trait T {
fn default(&self, arg: S) {
arg.mutate(); //~ ERROR: cannot borrow `arg` as mutable, as it is not declared as mutable
}
}
impl T for S {}
fn main() {
let s = S;
func(s);
s.method(s);
s.default(s);
(|arg: S| { arg.mutate() })(s);
//~^ ERROR: cannot borrow `arg` as mutable, as it is not declared as mutable
}
|