summary refs log tree commit diff
path: root/src/test/compile-fail/borrowck-call-method-from-mut-aliasable.rs
blob: 14e268e52adf99f71c3e53498dbdcf16287025ff (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
struct Foo {
    x: int,
}

impl Foo {
    fn f(&self) {}
    fn g(&const self) {}
    fn h(&mut self) {}
}

fn a(x: &mut Foo) {
    x.f(); //~ ERROR illegal borrow unless pure
    x.g();
    x.h();
}

fn b(x: &Foo) {
    x.f();
    x.g();
    x.h(); //~ ERROR illegal borrow
}

fn c(x: &const Foo) {
    x.f(); //~ ERROR illegal borrow unless pure
    x.g();
    x.h(); //~ ERROR illegal borrow
}

fn main() {
}