rust/src/test/compile-fail/borrowck-unchecked-with-borrow.rs

30 lines
535 B
Rust
Raw Normal View History

2012-05-23 06:13:54 -07:00
fn impure(_i: int) {}
// check that unchecked alone does not override borrowck:
2012-05-23 06:13:54 -07:00
fn foo(v: &const option<int>) {
alt *v {
some(i) {
//~^ ERROR illegal borrow unless pure: enum variant in aliasable, mutable location
2012-05-23 06:13:54 -07:00
unchecked {
impure(i); //~ NOTE impure due to access to impure function
2012-05-23 06:13:54 -07:00
}
}
none {
}
}
}
fn bar(v: &const option<int>) {
alt *v {
some(i) {
unsafe {
impure(i);
}
}
none {
}
}
}
fn main() {
}