2012-08-14 18:17:18 -07:00
|
|
|
// Tests that auto-ref can't create mutable aliases to immutable memory.
|
|
|
|
|
|
|
|
struct Foo {
|
2015-01-08 21:54:35 +11:00
|
|
|
x: isize
|
2012-08-14 18:17:18 -07:00
|
|
|
}
|
|
|
|
|
2013-05-31 15:17:22 -07:00
|
|
|
impl Foo {
|
|
|
|
pub fn printme(&mut self) {
|
2013-09-24 22:16:43 -07:00
|
|
|
println!("{}", self.x);
|
2012-08-14 18:17:18 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
let x = Foo { x: 3 };
|
2013-03-15 15:24:24 -04:00
|
|
|
x.printme(); //~ ERROR cannot borrow
|
2012-08-14 18:17:18 -07:00
|
|
|
}
|