]> git.lizzy.rs Git - rust.git/blob - tests/ui/borrowck/borrowck-auto-mut-ref-to-immut-var.rs
Merge commit '7f27e2e74ef957baa382dc05cf08df6368165c74' into clippyup
[rust.git] / tests / ui / borrowck / borrowck-auto-mut-ref-to-immut-var.rs
1 // Tests that auto-ref can't create mutable aliases to immutable memory.
2
3 struct Foo {
4     x: isize
5 }
6
7 impl Foo {
8     pub fn printme(&mut self) {
9         println!("{}", self.x);
10     }
11 }
12
13 fn main() {
14     let x = Foo { x: 3 };
15     x.printme();    //~ ERROR cannot borrow
16 }