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