]>
Commit | Line | Data |
---|---|---|
1a4d82fc | 1 | // Test method calls with self as an argument cannot subvert borrow checking. |
223e47cc | 2 | |
b7449926 XL |
3 | |
4 | ||
1a4d82fc | 5 | struct Foo; |
970d7e83 | 6 | |
1a4d82fc JJ |
7 | impl Foo { |
8 | fn bar(&self) {} | |
9 | fn baz(&mut self) {} | |
223e47cc LB |
10 | } |
11 | ||
12 | fn main() { | |
1a4d82fc JJ |
13 | let mut x = Foo; |
14 | let y = &mut x; | |
15 | Foo::bar(&x); //~ERROR cannot borrow `x` | |
b7449926 | 16 | y.use_mut(); |
1a4d82fc | 17 | |
85aaf69f SL |
18 | let mut x = Foo; |
19 | let y = &mut x; | |
20 | Foo::baz(&mut x); //~ERROR cannot borrow `x` | |
b7449926 | 21 | y.use_mut(); |
223e47cc | 22 | } |
b7449926 XL |
23 | |
24 | trait Fake { fn use_mut(&mut self) { } fn use_ref(&self) { } } | |
25 | impl<T> Fake for T { } |