rust/src/test/compile-fail/borrowck-confuse-region.rs
Niko Matsakis 5e36a99794 Refactor trans to replace lvalue and friends with Datum.
Also:
- report illegal move/ref combos whether or not ref comes first
- commented out fix for #3387, too restrictive and causes an ICE
2012-09-06 06:11:12 -07:00

17 lines
488 B
Rust

// Here we are checking that a reasonable error msg is provided.
//
// The current message is not ideal, but we used to say "borrowed
// pointer has lifetime &, but the borrowed value only has lifetime &"
// which is definitely no good.
fn get() -> &int {
//~^ NOTE borrowed pointer must be valid for the anonymous lifetime #1 defined on
//~^^ NOTE ...but borrowed value is only valid for the block at
let x = 3;
return &x;
//~^ ERROR illegal borrow
}
fn main() {}