rust/src/test/compile-fail/reference-in-loop.rs
Marijn Haverbeke 9ff6f816ba Fix handling of loops and conditionals in alias.rs
It now threads information about invalidated aliases through the AST
properly. This makes it more permissive for conditionals (invalidating
an alias in one branch doesn't prevent you from using it in another),
and less permissive for loops (it now properly notices when a loop
invalidates an alias that it might still use in another iteration).

Closes #1144
2011-11-15 13:29:57 +01:00

11 lines
166 B
Rust

// error-pattern: overwriting x will invalidate reference y
fn main() {
let x = [];
let &y = x;
while true {
log_err y;
x = [1];
}
}