]> git.lizzy.rs Git - rust.git/blob - src/test/ui/borrowck/borrowck-auto-mut-ref-to-immut-var.rs
Add 'src/tools/rust-analyzer/' from commit '977e12a0bdc3e329af179ef3a9d466af9eb613bb'
[rust.git] / src / test / 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 }