diff --git a/src/test/compile-fail/alias-mismatch.rs b/src/test/compile-fail/alias-mismatch.rs deleted file mode 100644 index 068e8c65ff5..00000000000 --- a/src/test/compile-fail/alias-mismatch.rs +++ /dev/null @@ -1,9 +0,0 @@ -// error-pattern:expected argument mode -use std; -import std::vec::map; - -fn main() { - fn f(i: uint) -> bool { true } - - let a = map(f, [5u]); -} diff --git a/src/test/compile-fail/aliasness-mismatch.rs b/src/test/compile-fail/aliasness-mismatch.rs deleted file mode 100644 index 8be70d8e29f..00000000000 --- a/src/test/compile-fail/aliasness-mismatch.rs +++ /dev/null @@ -1,8 +0,0 @@ -// -*- rust -*- -// error-pattern: mismatched types - -fn f(x: &int) { log_err x; } -fn h(x: int) { log_err x; } -fn main() { let g: fn(int) = f; g(10); g = h; g(10); } - - diff --git a/src/test/compile-fail/assign-alias.rs b/src/test/compile-fail/assign-alias.rs deleted file mode 100644 index b291b6d47b6..00000000000 --- a/src/test/compile-fail/assign-alias.rs +++ /dev/null @@ -1,5 +0,0 @@ -// error-pattern:assigning to immutable alias - -fn f(i: &int) { i += 2; } - -fn main() { f(1); } diff --git a/src/test/compile-fail/copy-a-resource.rs b/src/test/compile-fail/copy-a-resource.rs index 9e5e6f81666..0a1c65aecf9 100644 --- a/src/test/compile-fail/copy-a-resource.rs +++ b/src/test/compile-fail/copy-a-resource.rs @@ -1,5 +1,8 @@ // error-pattern:Copying a non-copyable type +// This is still not properly checked +// xfail-test + resource foo(i: int) { } fn main() { let x <- foo(10); let y = x; } diff --git a/src/test/compile-fail/unsafe-alias.rs b/src/test/compile-fail/unsafe-alias.rs index 80eaa661d1d..9b3e277a1fa 100644 --- a/src/test/compile-fail/unsafe-alias.rs +++ b/src/test/compile-fail/unsafe-alias.rs @@ -1,7 +1,12 @@ // error-pattern:may alias with argument -fn foo(x: &int, f: fn()) { log x; } +fn foo(x: &{mutable x: int}, f: fn()) { log x; } -fn whoknows(x: @mutable int) { *x = 10; } +fn whoknows(x: @mutable {mutable x: int}) { + *x = {mutable x: 10}; +} -fn main() { let box = @mutable 1; foo(*box, bind whoknows(box)); } +fn main() { + let box = @mutable {mutable x: 1}; + foo(*box, bind whoknows(box)); +} diff --git a/src/test/compile-fail/unsafe-mutable-alias.rs b/src/test/compile-fail/unsafe-mutable-alias.rs index 2f2a395778e..c94fca11d5a 100644 --- a/src/test/compile-fail/unsafe-mutable-alias.rs +++ b/src/test/compile-fail/unsafe-mutable-alias.rs @@ -1,5 +1,7 @@ // error-pattern:mutable alias to a variable that roots another alias -fn f(a: &int, b: &mutable int) -> int { b += 1; ret a + b; } +fn f(a: &{mutable x: int}, b: &mutable {mutable x: int}) -> int { + b.x += 1; ret a.x + b.x; +} -fn main() { let i = 4; log f(i, i); } +fn main() { let i = {mutable x: 4}; log f(i, i); } diff --git a/src/test/run-pass/argument-passing.rs b/src/test/run-pass/argument-passing.rs new file mode 100644 index 00000000000..1e4ca8e9dff --- /dev/null +++ b/src/test/run-pass/argument-passing.rs @@ -0,0 +1,18 @@ +fn f1(a: {mutable x: int}, b: &mutable int, c: -int) -> int { + let r = a.x + b + c; + a.x = 0; + b = 10; + c = 20; + ret r; +} + +fn f2(a: int, f: block(x: int)) -> int { f(1); ret a; } + +fn main() { + let a = {mutable x: 1}, b = 2, c = 3; + assert (f1(a, b, c) == 6); + assert (a.x == 0); + assert (b == 10); + assert (f2(a.x, {| x | a.x = 50; }) == 0); + assert (a.x == 50); +}