Skip to content

Commit e416518

Browse files
committed
update test cases to reflect new messages
1 parent d9a947c commit e416518

File tree

121 files changed

+534
-630
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

121 files changed

+534
-630
lines changed

src/test/compile-fail/array-not-vector.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,14 @@
1111
fn main() {
1212
let _x: i32 = [1, 2, 3];
1313
//~^ ERROR mismatched types
14-
//~| expected `i32`
15-
//~| found `[_; 3]`
16-
//~| expected i32
17-
//~| found array of 3 elements
14+
//~| expected type `i32`
15+
//~| found type `[_; 3]`
16+
//~| expected i32, found array of 3 elements
1817

1918
let x: &[i32] = &[1, 2, 3];
2019
let _y: &i32 = x;
2120
//~^ ERROR mismatched types
22-
//~| expected `&i32`
23-
//~| found `&[i32]`
24-
//~| expected i32
25-
//~| found slice
21+
//~| expected type `&i32`
22+
//~| found type `&[i32]`
23+
//~| expected i32, found slice
2624
}

src/test/compile-fail/associated-types-eq-3.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,9 @@ fn foo1<I: Foo<A=Bar>>(x: I) {
3232
fn foo2<I: Foo>(x: I) {
3333
let _: Bar = x.boo();
3434
//~^ ERROR mismatched types
35-
//~| expected `Bar`
36-
//~| found `<I as Foo>::A`
37-
//~| expected struct `Bar`
38-
//~| found associated type
35+
//~| expected type `Bar`
36+
//~| found type `<I as Foo>::A`
37+
//~| expected struct `Bar`, found associated type
3938
}
4039

4140

src/test/compile-fail/associated-types-path-2.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,7 @@ pub fn f2<T: Foo>(a: T) -> T::A {
2828
pub fn f1_int_int() {
2929
f1(2i32, 4i32);
3030
//~^ ERROR mismatched types
31-
//~| expected `u32`
32-
//~| found `i32`
31+
//~| expected u32, found i32
3332
}
3433

3534
pub fn f1_int_uint() {
@@ -49,8 +48,7 @@ pub fn f1_uint_int() {
4948
pub fn f2_int() {
5049
let _: i32 = f2(2i32);
5150
//~^ ERROR mismatched types
52-
//~| expected `i32`
53-
//~| found `u32`
51+
//~| expected i32, found u32
5452
}
5553

5654
pub fn main() { }

src/test/compile-fail/augmented-assignments.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,10 @@ impl AddAssign for Int {
2121
fn main() {
2222
let mut x = Int(1);
2323
x //~ error: use of moved value: `x`
24+
//~^ value used here after move
25+
//~| note: move occurs because `x` has type `Int`
2426
+=
25-
x; //~ note: `x` moved here because it has type `Int`, which is non-copyable
27+
x; //~ value moved here
2628

2729
let y = Int(2);
2830
y //~ error: cannot borrow immutable local variable `y` as mutable

src/test/compile-fail/bad-const-type.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@
1010

1111
static i: String = 10;
1212
//~^ ERROR mismatched types
13-
//~| expected `std::string::String`
14-
//~| found `_`
15-
//~| expected struct `std::string::String`
16-
//~| found integral variable
13+
//~| expected type `std::string::String`
14+
//~| found type `_`
15+
//~| expected struct `std::string::String`, found integral variable
1716
fn main() { println!("{}", i); }

src/test/compile-fail/bad-main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
fn main(x: isize) { } //~ ERROR: main function expects type
11+
fn main(x: isize) { } //~ ERROR: main function has wrong type

src/test/compile-fail/binop-move-semantics.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ fn mut_plus_immut() {
6262
&mut f
6363
+
6464
&f; //~ ERROR: cannot borrow `f` as immutable because it is also borrowed as mutable
65+
//~^ cannot borrow `f` as immutable because it is also borrowed as mutable
6566
}
6667

6768
fn immut_plus_mut() {
@@ -70,6 +71,7 @@ fn immut_plus_mut() {
7071
&f
7172
+
7273
&mut f; //~ ERROR: cannot borrow `f` as mutable because it is also borrowed as immutable
74+
//~^ cannot borrow `f` as mutable because it is also borrowed as immutable
7375
}
7476

7577
fn main() {}

src/test/compile-fail/block-must-not-have-result-while.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,8 @@
1111
fn main() {
1212
while true {
1313
true //~ ERROR mismatched types
14-
//~| expected `()`
15-
//~| found `bool`
16-
//~| expected ()
17-
//~| found bool
14+
//~| expected type `()`
15+
//~| found type `bool`
16+
//~| expected (), found bool
1817
}
1918
}

src/test/compile-fail/borrowck/borrowck-box-insensitivity.rs

Lines changed: 31 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -33,22 +33,28 @@ struct D {
3333
fn copy_after_move() {
3434
let a: Box<_> = box A { x: box 0, y: 1 };
3535
let _x = a.x;
36+
//~^ value moved here
3637
let _y = a.y; //~ ERROR use of moved
37-
//~^^ NOTE `a` moved here (through moving `a.x`)
38+
//~^ move occurs because `a.x` has type `Box<isize>`
39+
//~| value used here after move
3840
}
3941

4042
fn move_after_move() {
4143
let a: Box<_> = box B { x: box 0, y: box 1 };
4244
let _x = a.x;
45+
//~^ value moved here
4346
let _y = a.y; //~ ERROR use of moved
44-
//~^^ NOTE `a` moved here (through moving `a.x`)
47+
//~^ move occurs because `a.x` has type `Box<isize>`
48+
//~| value used here after move
4549
}
4650

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

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

8390
fn mut_borrow_after_borrow() {
8491
let mut a: Box<_> = box A { x: box 0, y: 1 };
8592
let _x = &a.x;
86-
//~^ NOTE previous borrow of `a` occurs here (through borrowing `a.x`)
93+
//~^ NOTE immutable borrow occurs here (via `a.x`)
8794
let _y = &mut a.y; //~ ERROR cannot borrow
95+
//~^ mutable borrow occurs here (via `a.y`)
8896
}
89-
//~^ NOTE previous borrow ends here
97+
//~^ NOTE immutable borrow ends here
9098

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

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

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

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

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

141156
fn mut_borrow_after_borrow_nested() {
142157
let mut a: Box<_> = box C { x: box A { x: box 0, y: 1 }, y: 2 };
143158
let _x = &a.x.x;
144-
//~^ NOTE previous borrow of `a.x.x` occurs here; the immutable borrow prevents
159+
//~^ immutable borrow occurs here
145160
let _y = &mut a.y; //~ ERROR cannot borrow
161+
//~^ mutable borrow occurs here
146162
}
147-
//~^ NOTE previous borrow ends here
163+
//~^ NOTE immutable borrow ends here
148164

149165
fn main() {
150166
copy_after_move();

src/test/compile-fail/borrowck/borrowck-closures-mut-of-imm.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ fn a(x: &isize) {
2424
//~^ ERROR cannot borrow
2525
let c2 = || set(&mut *x);
2626
//~^ ERROR cannot borrow
27-
//~| ERROR closure requires unique access
27+
//~| ERROR two closures require unique access to `x` at the same time
2828
}
2929

3030
fn main() {

src/test/compile-fail/borrowck/borrowck-closures-unique.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ fn c(x: &mut isize) {
3939

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

4545
fn e(x: &mut isize) {

src/test/compile-fail/borrowck/borrowck-lend-flow-loop.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ fn while_aliased_mut_cond(cond: bool, cond2: bool) {
109109
borrow(&*v); //~ ERROR cannot borrow
110110
if cond2 {
111111
x = &mut v; //~ ERROR cannot borrow
112+
//~^ ERROR cannot borrow
112113
}
113114
}
114115
}

src/test/compile-fail/borrowck/borrowck-mut-borrow-linear-errors.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ fn main() {
1919
match 1 {
2020
1 => { addr = &mut x; }
2121
//~^ ERROR cannot borrow `x` as mutable more than once at a time
22+
//~| ERROR cannot borrow `x` as mutable more than once at a time
2223
2 => { addr = &mut x; }
2324
//~^ ERROR cannot borrow `x` as mutable more than once at a time
2425
_ => { addr = &mut x; }

src/test/compile-fail/borrowck/borrowck-report-with-custom-diagnostic.rs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,21 +13,23 @@ fn main() {
1313
// Original borrow ends at end of function
1414
let mut x = 1;
1515
let y = &mut x;
16-
//~^ previous borrow of `x` occurs here; the mutable borrow prevents
16+
//~^ mutable borrow occurs here
1717
let z = &x; //~ ERROR cannot borrow
18+
//~^ immutable borrow occurs here
1819
}
19-
//~^ NOTE previous borrow ends here
20+
//~^ NOTE mutable borrow ends here
2021

2122
fn foo() {
2223
match true {
2324
true => {
2425
// Original borrow ends at end of match arm
2526
let mut x = 1;
2627
let y = &x;
27-
//~^ previous borrow of `x` occurs here; the immutable borrow prevents
28+
//~^ immutable borrow occurs here
2829
let z = &mut x; //~ ERROR cannot borrow
30+
//~^ mutable borrow occurs here
2931
}
30-
//~^ NOTE previous borrow ends here
32+
//~^ NOTE immutable borrow ends here
3133
false => ()
3234
}
3335
}
@@ -37,8 +39,9 @@ fn bar() {
3739
|| {
3840
let mut x = 1;
3941
let y = &mut x;
40-
//~^ previous borrow of `x` occurs here; the mutable borrow prevents
42+
//~^ first mutable borrow occurs here
4143
let z = &mut x; //~ ERROR cannot borrow
44+
//~^ second mutable borrow occurs here
4245
};
43-
//~^ NOTE previous borrow ends here
46+
//~^ NOTE first borrow ends here
4447
}

src/test/compile-fail/closure-wrong-kind.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,6 @@ fn bar<T: Fn(u32)>(_: T) {}
1717

1818
fn main() {
1919
let x = X;
20-
let closure = |_| foo(x); //~ ERROR E0524
20+
let closure = |_| foo(x); //~ ERROR E0525
2121
bar(closure);
2222
}

src/test/compile-fail/coerce-mut.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ fn main() {
1414
let x = 0;
1515
f(&x);
1616
//~^ ERROR mismatched types
17-
//~| expected `&mut i32`
18-
//~| found `&_`
17+
//~| expected type `&mut i32`
18+
//~| found type `&_`
1919
//~| values differ in mutability
2020
}

src/test/compile-fail/coercion-slice.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@
1313
fn main() {
1414
let _: &[i32] = [0];
1515
//~^ ERROR mismatched types
16-
//~| expected `&[i32]`
17-
//~| found `[_; 1]`
18-
//~| expected &-ptr
19-
//~| found array of 1 elements
16+
//~| expected type `&[i32]`
17+
//~| found type `[_; 1]`
18+
//~| expected &-ptr, found array of 1 elements
2019
}

src/test/compile-fail/cross-borrow-trait.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@ pub fn main() {
1919
// FIXME (#22405): Replace `Box::new` with `box` here when/if possible.
2020
let x: Box<Trait> = Box::new(Foo);
2121
let _y: &Trait = x; //~ ERROR mismatched types
22-
//~| expected `&Trait`
23-
//~| found `Box<Trait>`
24-
//~| expected &-ptr
25-
//~| found box
22+
//~| expected type `&Trait`
23+
//~| found type `Box<Trait>`
24+
//~| expected &-ptr, found box
2625
}

src/test/compile-fail/default_ty_param_conflict.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ fn main() {
2323
// Here, F is instantiated with $0=uint
2424
let x = foo();
2525
//~^ ERROR: mismatched types
26+
//~| expected type `usize`
27+
//~| found type `isize`
28+
//~| NOTE: conflicting type parameter defaults `usize` and `isize`
2629
//~| NOTE: conflicting type parameter defaults `usize` and `isize`
2730
//~| NOTE: ...that was applied to an unconstrained type variable here
2831

src/test/compile-fail/default_ty_param_conflict_cross_crate.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,11 @@ fn main() {
2424
//~^ NOTE: ...that also applies to the same type variable here
2525

2626
meh(foo);
27-
//~^ ERROR: mismatched types:
27+
//~^ ERROR: mismatched types
2828
//~| NOTE: conflicting type parameter defaults `bool` and `char`
29+
//~| NOTE: conflicting type parameter defaults `bool` and `char`
30+
//~| a second default is defined on `default_param_test::bleh`
2931
//~| NOTE: ...that was applied to an unconstrained type variable here
32+
//~| expected type `bool`
33+
//~| found type `char`
3034
}

0 commit comments

Comments
 (0)