Skip to content

Commit

Permalink
update test cases to reflect new messages
Browse files Browse the repository at this point in the history
  • Loading branch information
nikomatsakis committed May 2, 2016
1 parent d9a947c commit e416518
Show file tree
Hide file tree
Showing 121 changed files with 534 additions and 630 deletions.
14 changes: 6 additions & 8 deletions src/test/compile-fail/array-not-vector.rs
Expand Up @@ -11,16 +11,14 @@
fn main() {
let _x: i32 = [1, 2, 3];
//~^ ERROR mismatched types
//~| expected `i32`
//~| found `[_; 3]`
//~| expected i32
//~| found array of 3 elements
//~| expected type `i32`
//~| found type `[_; 3]`
//~| expected i32, found array of 3 elements

let x: &[i32] = &[1, 2, 3];
let _y: &i32 = x;
//~^ ERROR mismatched types
//~| expected `&i32`
//~| found `&[i32]`
//~| expected i32
//~| found slice
//~| expected type `&i32`
//~| found type `&[i32]`
//~| expected i32, found slice
}
7 changes: 3 additions & 4 deletions src/test/compile-fail/associated-types-eq-3.rs
Expand Up @@ -32,10 +32,9 @@ fn foo1<I: Foo<A=Bar>>(x: I) {
fn foo2<I: Foo>(x: I) {
let _: Bar = x.boo();
//~^ ERROR mismatched types
//~| expected `Bar`
//~| found `<I as Foo>::A`
//~| expected struct `Bar`
//~| found associated type
//~| expected type `Bar`
//~| found type `<I as Foo>::A`
//~| expected struct `Bar`, found associated type
}


Expand Down
6 changes: 2 additions & 4 deletions src/test/compile-fail/associated-types-path-2.rs
Expand Up @@ -28,8 +28,7 @@ pub fn f2<T: Foo>(a: T) -> T::A {
pub fn f1_int_int() {
f1(2i32, 4i32);
//~^ ERROR mismatched types
//~| expected `u32`
//~| found `i32`
//~| expected u32, found i32
}

pub fn f1_int_uint() {
Expand All @@ -49,8 +48,7 @@ pub fn f1_uint_int() {
pub fn f2_int() {
let _: i32 = f2(2i32);
//~^ ERROR mismatched types
//~| expected `i32`
//~| found `u32`
//~| expected i32, found u32
}

pub fn main() { }
4 changes: 3 additions & 1 deletion src/test/compile-fail/augmented-assignments.rs
Expand Up @@ -21,8 +21,10 @@ impl AddAssign for Int {
fn main() {
let mut x = Int(1);
x //~ error: use of moved value: `x`
//~^ value used here after move
//~| note: move occurs because `x` has type `Int`
+=
x; //~ note: `x` moved here because it has type `Int`, which is non-copyable
x; //~ value moved here

let y = Int(2);
y //~ error: cannot borrow immutable local variable `y` as mutable
Expand Down
7 changes: 3 additions & 4 deletions src/test/compile-fail/bad-const-type.rs
Expand Up @@ -10,8 +10,7 @@

static i: String = 10;
//~^ ERROR mismatched types
//~| expected `std::string::String`
//~| found `_`
//~| expected struct `std::string::String`
//~| found integral variable
//~| expected type `std::string::String`
//~| found type `_`
//~| expected struct `std::string::String`, found integral variable
fn main() { println!("{}", i); }
2 changes: 1 addition & 1 deletion src/test/compile-fail/bad-main.rs
Expand Up @@ -8,4 +8,4 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

fn main(x: isize) { } //~ ERROR: main function expects type
fn main(x: isize) { } //~ ERROR: main function has wrong type
2 changes: 2 additions & 0 deletions src/test/compile-fail/binop-move-semantics.rs
Expand Up @@ -62,6 +62,7 @@ fn mut_plus_immut() {
&mut f
+
&f; //~ ERROR: cannot borrow `f` as immutable because it is also borrowed as mutable
//~^ cannot borrow `f` as immutable because it is also borrowed as mutable
}

fn immut_plus_mut() {
Expand All @@ -70,6 +71,7 @@ fn immut_plus_mut() {
&f
+
&mut f; //~ ERROR: cannot borrow `f` as mutable because it is also borrowed as immutable
//~^ cannot borrow `f` as mutable because it is also borrowed as immutable
}

fn main() {}
7 changes: 3 additions & 4 deletions src/test/compile-fail/block-must-not-have-result-while.rs
Expand Up @@ -11,9 +11,8 @@
fn main() {
while true {
true //~ ERROR mismatched types
//~| expected `()`
//~| found `bool`
//~| expected ()
//~| found bool
//~| expected type `()`
//~| found type `bool`
//~| expected (), found bool
}
}
46 changes: 31 additions & 15 deletions src/test/compile-fail/borrowck/borrowck-box-insensitivity.rs
Expand Up @@ -33,22 +33,28 @@ struct D {
fn copy_after_move() {
let a: Box<_> = box A { x: box 0, y: 1 };
let _x = a.x;
//~^ value moved here
let _y = a.y; //~ ERROR use of moved
//~^^ NOTE `a` moved here (through moving `a.x`)
//~^ move occurs because `a.x` has type `Box<isize>`
//~| value used here after move
}

fn move_after_move() {
let a: Box<_> = box B { x: box 0, y: box 1 };
let _x = a.x;
//~^ value moved here
let _y = a.y; //~ ERROR use of moved
//~^^ NOTE `a` moved here (through moving `a.x`)
//~^ move occurs because `a.x` has type `Box<isize>`
//~| value used here after move
}

fn borrow_after_move() {
let a: Box<_> = box A { x: box 0, y: 1 };
let _x = a.x;
//~^ value moved here
let _y = &a.y; //~ ERROR use of moved
//~^^ NOTE `a` moved here (through moving `a.x`)
//~^ move occurs because `a.x` has type `Box<isize>`
//~| value used here after move
}

fn move_after_borrow() {
Expand All @@ -75,44 +81,52 @@ fn move_after_mut_borrow() {
fn borrow_after_mut_borrow() {
let mut a: Box<_> = box A { x: box 0, y: 1 };
let _x = &mut a.x;
//~^ NOTE previous borrow of `a` occurs here (through borrowing `a.x`);
//~^ NOTE mutable borrow occurs here (via `a.x`)
let _y = &a.y; //~ ERROR cannot borrow
//~^ immutable borrow occurs here (via `a.y`)
}
//~^ NOTE previous borrow ends here
//~^ NOTE mutable borrow ends here

fn mut_borrow_after_borrow() {
let mut a: Box<_> = box A { x: box 0, y: 1 };
let _x = &a.x;
//~^ NOTE previous borrow of `a` occurs here (through borrowing `a.x`)
//~^ NOTE immutable borrow occurs here (via `a.x`)
let _y = &mut a.y; //~ ERROR cannot borrow
//~^ mutable borrow occurs here (via `a.y`)
}
//~^ NOTE previous borrow ends here
//~^ NOTE immutable borrow ends here

fn copy_after_move_nested() {
let a: Box<_> = box C { x: box A { x: box 0, y: 1 }, y: 2 };
let _x = a.x.x;
//~^ NOTE `a.x.x` moved here because it has type `Box<isize>`, which is moved by default
//~^ value moved here
let _y = a.y; //~ ERROR use of collaterally moved
//~^ NOTE move occurs because `a.x.x` has type `Box<isize>`
//~| value used here after move
}

fn move_after_move_nested() {
let a: Box<_> = box D { x: box A { x: box 0, y: 1 }, y: box 2 };
let _x = a.x.x;
//~^ NOTE `a.x.x` moved here because it has type `Box<isize>`, which is moved by default
//~^ value moved here
let _y = a.y; //~ ERROR use of collaterally moved
//~^ NOTE move occurs because `a.x.x` has type `Box<isize>`
//~| value used here after move
}

fn borrow_after_move_nested() {
let a: Box<_> = box C { x: box A { x: box 0, y: 1 }, y: 2 };
let _x = a.x.x;
//~^ NOTE `a.x.x` moved here because it has type `Box<isize>`, which is moved by default
//~^ value moved here
let _y = &a.y; //~ ERROR use of collaterally moved
//~^ NOTE move occurs because `a.x.x` has type `Box<isize>`
//~| value used here after move
}

fn move_after_borrow_nested() {
let a: Box<_> = box D { x: box A { x: box 0, y: 1 }, y: box 2 };
let _x = &a.x.x;
//~^ NOTE borrow of `a.x.x` occurs here
//~^ borrow of `a.x.x` occurs here
let _y = a.y; //~ ERROR cannot move
}

Expand All @@ -133,18 +147,20 @@ fn move_after_mut_borrow_nested() {
fn borrow_after_mut_borrow_nested() {
let mut a: Box<_> = box C { x: box A { x: box 0, y: 1 }, y: 2 };
let _x = &mut a.x.x;
//~^ NOTE previous borrow of `a.x.x` occurs here; the mutable borrow prevents
//~^ mutable borrow occurs here
let _y = &a.y; //~ ERROR cannot borrow
//~^ immutable borrow occurs here
}
//~^ NOTE previous borrow ends here
//~^ NOTE mutable borrow ends here

fn mut_borrow_after_borrow_nested() {
let mut a: Box<_> = box C { x: box A { x: box 0, y: 1 }, y: 2 };
let _x = &a.x.x;
//~^ NOTE previous borrow of `a.x.x` occurs here; the immutable borrow prevents
//~^ immutable borrow occurs here
let _y = &mut a.y; //~ ERROR cannot borrow
//~^ mutable borrow occurs here
}
//~^ NOTE previous borrow ends here
//~^ NOTE immutable borrow ends here

fn main() {
copy_after_move();
Expand Down
Expand Up @@ -24,7 +24,7 @@ fn a(x: &isize) {
//~^ ERROR cannot borrow
let c2 = || set(&mut *x);
//~^ ERROR cannot borrow
//~| ERROR closure requires unique access
//~| ERROR two closures require unique access to `x` at the same time
}

fn main() {
Expand Down
2 changes: 1 addition & 1 deletion src/test/compile-fail/borrowck/borrowck-closures-unique.rs
Expand Up @@ -39,7 +39,7 @@ fn c(x: &mut isize) {

fn d(x: &mut isize) {
let c1 = || set(x);
let c2 = || set(x); //~ ERROR closure requires unique access to `x`
let c2 = || set(x); //~ ERROR two closures require unique access to `x` at the same time
}

fn e(x: &mut isize) {
Expand Down
1 change: 1 addition & 0 deletions src/test/compile-fail/borrowck/borrowck-lend-flow-loop.rs
Expand Up @@ -109,6 +109,7 @@ fn while_aliased_mut_cond(cond: bool, cond2: bool) {
borrow(&*v); //~ ERROR cannot borrow
if cond2 {
x = &mut v; //~ ERROR cannot borrow
//~^ ERROR cannot borrow
}
}
}
Expand Down
Expand Up @@ -19,6 +19,7 @@ fn main() {
match 1 {
1 => { addr = &mut x; }
//~^ ERROR cannot borrow `x` as mutable more than once at a time
//~| ERROR cannot borrow `x` as mutable more than once at a time
2 => { addr = &mut x; }
//~^ ERROR cannot borrow `x` as mutable more than once at a time
_ => { addr = &mut x; }
Expand Down
Expand Up @@ -13,21 +13,23 @@ fn main() {
// Original borrow ends at end of function
let mut x = 1;
let y = &mut x;
//~^ previous borrow of `x` occurs here; the mutable borrow prevents
//~^ mutable borrow occurs here
let z = &x; //~ ERROR cannot borrow
//~^ immutable borrow occurs here
}
//~^ NOTE previous borrow ends here
//~^ NOTE mutable borrow ends here

fn foo() {
match true {
true => {
// Original borrow ends at end of match arm
let mut x = 1;
let y = &x;
//~^ previous borrow of `x` occurs here; the immutable borrow prevents
//~^ immutable borrow occurs here
let z = &mut x; //~ ERROR cannot borrow
//~^ mutable borrow occurs here
}
//~^ NOTE previous borrow ends here
//~^ NOTE immutable borrow ends here
false => ()
}
}
Expand All @@ -37,8 +39,9 @@ fn bar() {
|| {
let mut x = 1;
let y = &mut x;
//~^ previous borrow of `x` occurs here; the mutable borrow prevents
//~^ first mutable borrow occurs here
let z = &mut x; //~ ERROR cannot borrow
//~^ second mutable borrow occurs here
};
//~^ NOTE previous borrow ends here
//~^ NOTE first borrow ends here
}
2 changes: 1 addition & 1 deletion src/test/compile-fail/closure-wrong-kind.rs
Expand Up @@ -17,6 +17,6 @@ fn bar<T: Fn(u32)>(_: T) {}

fn main() {
let x = X;
let closure = |_| foo(x); //~ ERROR E0524
let closure = |_| foo(x); //~ ERROR E0525
bar(closure);
}
4 changes: 2 additions & 2 deletions src/test/compile-fail/coerce-mut.rs
Expand Up @@ -14,7 +14,7 @@ fn main() {
let x = 0;
f(&x);
//~^ ERROR mismatched types
//~| expected `&mut i32`
//~| found `&_`
//~| expected type `&mut i32`
//~| found type `&_`
//~| values differ in mutability
}
7 changes: 3 additions & 4 deletions src/test/compile-fail/coercion-slice.rs
Expand Up @@ -13,8 +13,7 @@
fn main() {
let _: &[i32] = [0];
//~^ ERROR mismatched types
//~| expected `&[i32]`
//~| found `[_; 1]`
//~| expected &-ptr
//~| found array of 1 elements
//~| expected type `&[i32]`
//~| found type `[_; 1]`
//~| expected &-ptr, found array of 1 elements
}
7 changes: 3 additions & 4 deletions src/test/compile-fail/cross-borrow-trait.rs
Expand Up @@ -19,8 +19,7 @@ pub fn main() {
// FIXME (#22405): Replace `Box::new` with `box` here when/if possible.
let x: Box<Trait> = Box::new(Foo);
let _y: &Trait = x; //~ ERROR mismatched types
//~| expected `&Trait`
//~| found `Box<Trait>`
//~| expected &-ptr
//~| found box
//~| expected type `&Trait`
//~| found type `Box<Trait>`
//~| expected &-ptr, found box
}
3 changes: 3 additions & 0 deletions src/test/compile-fail/default_ty_param_conflict.rs
Expand Up @@ -23,6 +23,9 @@ fn main() {
// Here, F is instantiated with $0=uint
let x = foo();
//~^ ERROR: mismatched types
//~| expected type `usize`
//~| found type `isize`
//~| NOTE: conflicting type parameter defaults `usize` and `isize`
//~| NOTE: conflicting type parameter defaults `usize` and `isize`
//~| NOTE: ...that was applied to an unconstrained type variable here

Expand Down
Expand Up @@ -24,7 +24,11 @@ fn main() {
//~^ NOTE: ...that also applies to the same type variable here

meh(foo);
//~^ ERROR: mismatched types:
//~^ ERROR: mismatched types
//~| NOTE: conflicting type parameter defaults `bool` and `char`
//~| NOTE: conflicting type parameter defaults `bool` and `char`
//~| a second default is defined on `default_param_test::bleh`
//~| NOTE: ...that was applied to an unconstrained type variable here
//~| expected type `bool`
//~| found type `char`
}

0 comments on commit e416518

Please sign in to comment.