This commit is contained in:
parent
1779ab4754
commit
589ee65fd4
12 changed files with 365 additions and 28 deletions
11
src/test/compile-fail/arc-rw-cond-shouldnt-escape.rs
Normal file
11
src/test/compile-fail/arc-rw-cond-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_cond |_one, cond| {
|
||||
y = some(cond);
|
||||
}
|
||||
option::unwrap(y).wait();
|
||||
}
|
||||
12
src/test/compile-fail/arc-rw-read-mode-shouldnt-escape.rs
Normal file
12
src/test/compile-fail/arc-rw-read-mode-shouldnt-escape.rs
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
// 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_downgrade |write_mode| {
|
||||
y = some(x.downgrade(write_mode));
|
||||
}
|
||||
// Adding this line causes a method unification failure instead
|
||||
// do (&option::unwrap(y)).read |state| { assert *state == 1; }
|
||||
}
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
// 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_downgrade |write_mode| {
|
||||
do (&write_mode).write_cond |_one, cond| {
|
||||
y = some(cond);
|
||||
}
|
||||
}
|
||||
option::unwrap(y).wait();
|
||||
}
|
||||
12
src/test/compile-fail/arc-rw-write-mode-shouldnt-escape.rs
Normal file
12
src/test/compile-fail/arc-rw-write-mode-shouldnt-escape.rs
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
// 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_downgrade |write_mode| {
|
||||
y = some(write_mode);
|
||||
}
|
||||
// Adding this line causes a method unification failure instead
|
||||
// do (&option::unwrap(y)).write |state| { assert *state == 1; }
|
||||
}
|
||||
11
src/test/compile-fail/sync-rwlock-cond-shouldnt-escape.rs
Normal file
11
src/test/compile-fail/sync-rwlock-cond-shouldnt-escape.rs
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
// error-pattern: reference is not valid outside of its lifetime
|
||||
use std;
|
||||
import std::sync;
|
||||
fn main() {
|
||||
let x = ~sync::rwlock();
|
||||
let mut y = none;
|
||||
do x.write_cond |cond| {
|
||||
y = some(cond);
|
||||
}
|
||||
option::unwrap(y).wait();
|
||||
}
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
// error-pattern: reference is not valid outside of its lifetime
|
||||
use std;
|
||||
import std::sync;
|
||||
fn main() {
|
||||
let x = ~sync::rwlock();
|
||||
let mut y = none;
|
||||
do x.write_downgrade |write_mode| {
|
||||
y = some(x.downgrade(write_mode));
|
||||
}
|
||||
// Adding this line causes a method unification failure instead
|
||||
// do (&option::unwrap(y)).read { }
|
||||
}
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
// error-pattern: reference is not valid outside of its lifetime
|
||||
use std;
|
||||
import std::sync;
|
||||
fn main() {
|
||||
let x = ~sync::rwlock();
|
||||
let mut y = none;
|
||||
do x.write_downgrade |write_mode| {
|
||||
do (&write_mode).write_cond |cond| {
|
||||
y = some(cond);
|
||||
}
|
||||
}
|
||||
option::unwrap(y).wait();
|
||||
}
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
// error-pattern: reference is not valid outside of its lifetime
|
||||
use std;
|
||||
import 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 { }
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue