1
Fork 0
rust/src/test/compile-fail/regions-escape-loop-via-variable.rs
Gareth Daniel Smith 6d86969260 change the test suite //! kind syntax to //~ kind in order to avoid a
conflict with the new single-line-sugared-inner-doc-comment (`//! ...`).
2012-06-30 12:23:59 +01:00

14 lines
308 B
Rust

fn main() {
let x = 3;
// Here, the variable `p` gets inferred to a type with a lifetime
// of the loop body. The regionck then determines that this type
// is invalid.
let mut p = //~ ERROR reference is not valid
&x;
loop {
let x = 1 + *p;
p = &x;
}
}