Add cfail test arc-rw-state-shouldnt-escape
This commit is contained in:
parent
fa8fc4b2b5
commit
f6f9333d5c
1 changed files with 11 additions and 0 deletions
11
src/test/compile-fail/arc-rw-state-shouldnt-escape.rs
Normal file
11
src/test/compile-fail/arc-rw-state-shouldnt-escape.rs
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
// error-pattern: reference is not valid outside of its lifetime
|
||||
use std;
|
||||
import std::arc;
|
||||
fn main() {
|
||||
let x = ~arc::rw_arc(1);
|
||||
let mut y = none;
|
||||
do x.write |one| {
|
||||
y = some(one);
|
||||
}
|
||||
*option::unwrap(y) = 2;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue