rust/src/test/ui/mut/mutable-class-fields.rs

21 lines
355 B
Rust
Raw Normal View History

// revisions: ast mir
//[mir]compile-flags: -Z borrowck=mir
struct Cat {
meows : usize,
how_hungry : isize,
2012-09-05 17:58:43 -05:00
}
fn cat(in_x : usize, in_y : isize) -> Cat {
Cat {
2012-09-05 17:58:43 -05:00
meows: in_x,
how_hungry: in_y
}
}
fn main() {
let nyan : Cat = cat(52, 99);
nyan.how_hungry = 0; //[ast]~ ERROR cannot assign
//[mir]~^ ERROR cannot assign
}