5d32d03b89
What we now do is to create a region variable for each & expression (and also each borrow). The lifetime of this variable will be checked by borrowck to ensure it is not greater than the lifetime of the underlying data. This both leads to shorter lifetimes in some cases but also longer in others, such as taking the address to the interior of unique boxes tht are rooted in region pointers (e.g., returning a pointer to the interior of a sendable map). This may lead to issue #2977 if the rvalue is not POD, because we may drop the data in trans sooner than borrowck expects us to. Need to work out precisely where that fix ought to occur.
24 lines
424 B
Rust
24 lines
424 B
Rust
class dog {
|
|
let mut cats_chased: uint;
|
|
|
|
new() {
|
|
self.cats_chased = 0u;
|
|
}
|
|
|
|
fn chase_cat() {
|
|
let p: &static/mut uint = &mut self.cats_chased; //~ ERROR illegal borrow
|
|
*p += 1u;
|
|
}
|
|
|
|
fn chase_cat_2() {
|
|
let p: &blk/mut uint = &mut self.cats_chased;
|
|
*p += 1u;
|
|
}
|
|
}
|
|
|
|
fn main() {
|
|
let d = dog();
|
|
d.chase_cat();
|
|
#debug["cats_chased: %u", d.cats_chased];
|
|
}
|