summary refs log tree commit diff
path: root/src/test/compile-fail/auto-ref-borrowck-failure.rs
blob: 72c7a2f25854c23757fd71986825f41a1bb2bf60 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
// Tests that auto-ref can't create mutable aliases to immutable memory.

struct Foo {
    x: int
}

trait Stuff {
    fn printme();
}

impl &mut Foo : Stuff {
    fn printme() {
        io::println(fmt!("%d", self.x));
    }
}

fn main() {
    let x = Foo { x: 3 };
    x.printme();    //~ ERROR illegal borrow
}