]> git.lizzy.rs Git - rust.git/blob - tests/ui/borrowck/borrowck-auto-mut-ref-to-immut-var.rs
Rollup merge of #106726 - cmorin6:fix-comment-typos, r=Nilstrieb
[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 }