summary refs log tree commit diff
path: root/src/test/compile-fail/sync-rwlock-write-mode-shouldnt-escape.rs
blob: 883d32951219f0cd8cdcdce7edc94048479e543c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
// error-pattern: reference is not valid outside of its lifetime
extern mod std;
use std::sync;
fn main() {
    let x = ~sync::RWlock();
    let mut y = None;
    do x.write_downgrade |write_mode| {
        y = Some(write_mode);
    }
    // Adding this line causes a method unification failure instead
    // do (&option::unwrap(y)).write { }
}