diff options
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/compile-fail/access-mode-in-closures.rs | 10 | ||||
| -rw-r--r-- | src/test/run-fail/unwind-lambda.rs | 2 | ||||
| -rw-r--r-- | src/test/run-pass/last-use-corner-cases.rs | 4 | ||||
| -rw-r--r-- | src/test/run-pass/monad.rs | 4 |
4 files changed, 16 insertions, 4 deletions
diff --git a/src/test/compile-fail/access-mode-in-closures.rs b/src/test/compile-fail/access-mode-in-closures.rs new file mode 100644 index 00000000000..32ac756aaff --- /dev/null +++ b/src/test/compile-fail/access-mode-in-closures.rs @@ -0,0 +1,10 @@ +enum sty = ~[int]; + +fn unpack(unpack: &fn(v: &sty) -> ~[int]) {} + +fn main() { + let foo = unpack(|s| { + // Test that `s` is moved here. + match *s { sty(v) => v } //~ ERROR moving out of dereference of immutable & pointer + }); +} diff --git a/src/test/run-fail/unwind-lambda.rs b/src/test/run-fail/unwind-lambda.rs index 08457f07143..aee6f4e480c 100644 --- a/src/test/run-fail/unwind-lambda.rs +++ b/src/test/run-fail/unwind-lambda.rs @@ -15,7 +15,7 @@ fn main() { let carrots = @~"crunchy"; fn@(tasties: @~str, macerate: fn(~str)) { - macerate(*tasties); + macerate(copy *tasties); } (carrots, |food| { let mush = food + cheese; let f = fn@() { diff --git a/src/test/run-pass/last-use-corner-cases.rs b/src/test/run-pass/last-use-corner-cases.rs index b4077863852..1dfccac8bce 100644 --- a/src/test/run-pass/last-use-corner-cases.rs +++ b/src/test/run-pass/last-use-corner-cases.rs @@ -39,6 +39,6 @@ fn main() { // Verify that blocks can't interfere with each other. fn two_blocks(a: fn(), b: fn()) { a(); b(); a(); b(); } let q = ~50; - two_blocks(|| { let a = q; assert *a == 50;}, - || { let a = q; assert *a == 50;}); + two_blocks(|| { let a = copy q; assert *a == 50;}, + || { let a = copy q; assert *a == 50;}); } diff --git a/src/test/run-pass/monad.rs b/src/test/run-pass/monad.rs index 8abc8236b65..210defa5789 100644 --- a/src/test/run-pass/monad.rs +++ b/src/test/run-pass/monad.rs @@ -43,6 +43,8 @@ fn transform(x: Option<int>) -> Option<~str> { fn main() { assert transform(Some(10)) == Some(~"11"); assert transform(None) == None; - assert (~[~"hi"]).bind(|x| ~[x, x + ~"!"] ).bind(|x| ~[x, x + ~"?"] ) == + assert (~[~"hi"]) + .bind(|x| ~[copy x, x + ~"!"] ) + .bind(|x| ~[copy x, x + ~"?"] ) == ~[~"hi", ~"hi?", ~"hi!", ~"hi!?"]; } |
