diff options
| author | Tim Chevalier <chevalier@alum.wellesley.edu> | 2012-10-05 14:58:42 -0700 |
|---|---|---|
| committer | Tim Chevalier <chevalier@alum.wellesley.edu> | 2012-10-05 15:37:01 -0700 |
| commit | e16dbb7888504ef5d0de0c14493fc8ecc492ee30 (patch) | |
| tree | 80c1bde3c3f3b0cf47993dfe769418cc2ac55323 /src/test | |
| parent | e3cb70fa8a6f9163352f26ae2614ab4c9a261838 (diff) | |
| download | rust-e16dbb7888504ef5d0de0c14493fc8ecc492ee30.tar.gz rust-e16dbb7888504ef5d0de0c14493fc8ecc492ee30.zip | |
Demode some code using by-mutbl-ref; warn about by-mutbl-ref
The parser now warns about use of mutbl-ref mode, though it's kind of a lie since this commit doesn't remove support for the mode. Changed move_val_init to have stage0 and stage1/2 versions, the latter of which is demoded. Changed the type that the typechecker expects the move_val_init intrinsic to have. After this is pushed, I can make a new snapshot, which will remove the need for the stage0 versions.
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/compile-fail/borrowck-lend-args.rs | 4 | ||||
| -rw-r--r-- | src/test/compile-fail/deprecated-mode-fn-arg.rs | 2 | ||||
| -rw-r--r-- | src/test/compile-fail/issue-511.rs | 6 | ||||
| -rw-r--r-- | src/test/compile-fail/liveness-dead.rs | 4 | ||||
| -rw-r--r-- | src/test/compile-fail/liveness-move-from-args.rs | 4 | ||||
| -rw-r--r-- | src/test/compile-fail/liveness-unused.rs | 2 | ||||
| -rw-r--r-- | src/test/compile-fail/mutable-arguments.rs | 12 | ||||
| -rw-r--r-- | src/test/run-pass/intrinsic-move-val.rs | 6 |
8 files changed, 19 insertions, 21 deletions
diff --git a/src/test/compile-fail/borrowck-lend-args.rs b/src/test/compile-fail/borrowck-lend-args.rs index 3cb7009ee27..79f52b93612 100644 --- a/src/test/compile-fail/borrowck-lend-args.rs +++ b/src/test/compile-fail/borrowck-lend-args.rs @@ -4,8 +4,8 @@ fn borrow_from_arg_imm_ref(&&v: ~int) { borrow(v); } -fn borrow_from_arg_mut_ref(&v: ~int) { - borrow(v); //~ ERROR illegal borrow unless pure +fn borrow_from_arg_mut_ref(v: &mut ~int) { + borrow(*v); //~ ERROR illegal borrow unless pure //~^ NOTE impure due to access to impure function } diff --git a/src/test/compile-fail/deprecated-mode-fn-arg.rs b/src/test/compile-fail/deprecated-mode-fn-arg.rs index 5afffb59dfc..2c20e604f50 100644 --- a/src/test/compile-fail/deprecated-mode-fn-arg.rs +++ b/src/test/compile-fail/deprecated-mode-fn-arg.rs @@ -1,9 +1,11 @@ #[forbid(deprecated_mode)]; fn foo(_f: fn(&i: int)) { //~ ERROR explicit mode + //~^ WARNING Obsolete syntax has no effect } type Bar = fn(&i: int); //~ ERROR explicit mode + //~^ WARNING Obsolete syntax has no effect fn main() { } \ No newline at end of file diff --git a/src/test/compile-fail/issue-511.rs b/src/test/compile-fail/issue-511.rs index a3498dd1968..02a3082dc10 100644 --- a/src/test/compile-fail/issue-511.rs +++ b/src/test/compile-fail/issue-511.rs @@ -1,11 +1,11 @@ extern mod std; use cmp::Eq; -fn f<T:Eq>(&o: Option<T>) { - assert o == option::None; +fn f<T:Eq>(o: &mut Option<T>) { + assert *o == option::None; } fn main() { - f::<int>(option::None); + f::<int>(&mut option::None); //~^ ERROR illegal borrow: creating mutable alias to static item } diff --git a/src/test/compile-fail/liveness-dead.rs b/src/test/compile-fail/liveness-dead.rs index a115d7c4e34..834457940be 100644 --- a/src/test/compile-fail/liveness-dead.rs +++ b/src/test/compile-fail/liveness-dead.rs @@ -1,5 +1,5 @@ -fn f1(&x: int) { - x = 1; // no error +fn f1(x: &mut int) { + *x = 1; // no error } fn f2() { diff --git a/src/test/compile-fail/liveness-move-from-args.rs b/src/test/compile-fail/liveness-move-from-args.rs index 27e7e51b405..27e9d3b60dc 100644 --- a/src/test/compile-fail/liveness-move-from-args.rs +++ b/src/test/compile-fail/liveness-move-from-args.rs @@ -4,10 +4,6 @@ fn from_by_value_arg(++x: int) { take(x); //~ ERROR illegal move from argument `x`, which is not copy or move mode } -fn from_by_mut_ref_arg(&x: int) { - take(x); //~ ERROR illegal move from argument `x`, which is not copy or move mode -} - fn from_by_ref_arg(&&x: int) { take(x); //~ ERROR illegal move from argument `x`, which is not copy or move mode } diff --git a/src/test/compile-fail/liveness-unused.rs b/src/test/compile-fail/liveness-unused.rs index 7db02897112..8b2fef7cd35 100644 --- a/src/test/compile-fail/liveness-unused.rs +++ b/src/test/compile-fail/liveness-unused.rs @@ -2,7 +2,7 @@ fn f1(x: int) { //~^ WARNING unused variable: `x` } -fn f1b(&x: int) { +fn f1b(x: &mut int) { //~^ WARNING unused variable: `x` } diff --git a/src/test/compile-fail/mutable-arguments.rs b/src/test/compile-fail/mutable-arguments.rs index 4fcb73e8516..d84c9401e25 100644 --- a/src/test/compile-fail/mutable-arguments.rs +++ b/src/test/compile-fail/mutable-arguments.rs @@ -1,28 +1,28 @@ // Note: it would be nice to give fewer warnings in these cases. -fn mutate_by_mut_ref(&x: uint) { - x = 0u; +fn mutate_by_mut_ref(x: &mut uint) { + *x = 0; } fn mutate_by_ref(&&x: uint) { //~^ WARNING unused variable: `x` - x = 0u; //~ ERROR assigning to argument + x = 0; //~ ERROR assigning to argument } fn mutate_by_val(++x: uint) { //~^ WARNING unused variable: `x` - x = 0u; //~ ERROR assigning to argument + x = 0; //~ ERROR assigning to argument } fn mutate_by_copy(+x: uint) { //~^ WARNING unused variable: `x` - x = 0u; //~ ERROR assigning to argument + x = 0; //~ ERROR assigning to argument //~^ WARNING value assigned to `x` is never read } fn mutate_by_move(-x: uint) { //~^ WARNING unused variable: `x` - x = 0u; //~ ERROR assigning to argument + x = 0; //~ ERROR assigning to argument //~^ WARNING value assigned to `x` is never read } diff --git a/src/test/run-pass/intrinsic-move-val.rs b/src/test/run-pass/intrinsic-move-val.rs index b7f2115f45d..683321aac3d 100644 --- a/src/test/run-pass/intrinsic-move-val.rs +++ b/src/test/run-pass/intrinsic-move-val.rs @@ -1,13 +1,13 @@ #[abi = "rust-intrinsic"] extern mod rusti { #[legacy_exports]; - fn move_val_init<T>(&dst: T, -src: T); - fn move_val<T>(&dst: T, -src: T); + fn move_val_init<T>(dst: &mut T, -src: T); + fn move_val<T>(dst: &mut T, -src: T); } fn main() { let mut x = @1; let mut y = @2; - rusti::move_val(y, x); + rusti::move_val(&mut y, x); assert *y == 1; } \ No newline at end of file |
