mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-23 07:14:28 +00:00
17 lines
271 B
Rust
17 lines
271 B
Rust
// Tests that auto-ref can't create mutable aliases to immutable memory.
|
|
|
|
struct Foo {
|
|
x: isize
|
|
}
|
|
|
|
impl Foo {
|
|
pub fn printme(&mut self) {
|
|
println!("{}", self.x);
|
|
}
|
|
}
|
|
|
|
fn main() {
|
|
let x = Foo { x: 3 };
|
|
x.printme(); //~ ERROR cannot borrow
|
|
}
|