Skip to content

Commit f699d41

Browse files
committed
update tests
1 parent 40af99d commit f699d41

33 files changed

+334
-295
lines changed

src/test/ui/coercion/coerce-expect-unsized-ascribed.rs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,29 @@
11
// A version of coerce-expect-unsized that uses type ascription.
22
// Doesn't work so far, but supposed to work eventually
33

4+
// check-pass
5+
46
#![feature(box_syntax, type_ascription)]
57

68
use std::fmt::Debug;
79

810
pub fn main() {
9-
let _ = box { [1, 2, 3] }: Box<[i32]>; //~ ERROR mismatched types
10-
let _ = box if true { [1, 2, 3] } else { [1, 3, 4] }: Box<[i32]>; //~ ERROR mismatched types
11+
let _ = box { [1, 2, 3] }: Box<[i32]>;
12+
let _ = box if true { [1, 2, 3] } else { [1, 3, 4] }: Box<[i32]>;
1113
let _ = box match true { true => [1, 2, 3], false => [1, 3, 4] }: Box<[i32]>;
12-
//~^ ERROR mismatched types
13-
let _ = box { |x| (x as u8) }: Box<dyn Fn(i32) -> _>; //~ ERROR mismatched types
14-
let _ = box if true { false } else { true }: Box<dyn Debug>; //~ ERROR mismatched types
15-
let _ = box match true { true => 'a', false => 'b' }: Box<dyn Debug>; //~ ERROR mismatched types
14+
let _ = box { |x| (x as u8) }: Box<dyn Fn(i32) -> _>;
15+
let _ = box if true { false } else { true }: Box<dyn Debug>;
16+
let _ = box match true { true => 'a', false => 'b' }: Box<dyn Debug>;
1617

17-
let _ = &{ [1, 2, 3] }: &[i32]; //~ ERROR mismatched types
18-
let _ = &if true { [1, 2, 3] } else { [1, 3, 4] }: &[i32]; //~ ERROR mismatched types
18+
let _ = &{ [1, 2, 3] }: &[i32];
19+
let _ = &if true { [1, 2, 3] } else { [1, 3, 4] }: &[i32];
1920
let _ = &match true { true => [1, 2, 3], false => [1, 3, 4] }: &[i32];
20-
//~^ ERROR mismatched types
21-
let _ = &{ |x| (x as u8) }: &dyn Fn(i32) -> _; //~ ERROR mismatched types
22-
let _ = &if true { false } else { true }: &dyn Debug; //~ ERROR mismatched types
23-
let _ = &match true { true => 'a', false => 'b' }: &dyn Debug; //~ ERROR mismatched types
21+
let _ = &{ |x| (x as u8) }: &dyn Fn(i32) -> _;
22+
let _ = &if true { false } else { true }: &dyn Debug;
23+
let _ = &match true { true => 'a', false => 'b' }: &dyn Debug;
2424

25-
let _ = Box::new([1, 2, 3]): Box<[i32]>; //~ ERROR mismatched types
26-
let _ = Box::new(|x| (x as u8)): Box<dyn Fn(i32) -> _>; //~ ERROR mismatched types
25+
let _ = Box::new([1, 2, 3]): Box<[i32]>;
26+
let _ = Box::new(|x| (x as u8)): Box<dyn Fn(i32) -> _>;
2727

2828
let _ = vec![
2929
Box::new(|x| (x as u8)),

src/test/ui/coercion/coerce-expect-unsized-ascribed.stderr

Lines changed: 0 additions & 129 deletions
This file was deleted.
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
#![feature(type_ascription)]
22

3-
// build-pass
4-
53
fn foo(_arg : [&[u32];3]) {}
64

75
fn main() {
86
let arr = [4,5,6];
97
foo([&arr : &[u32]; 3]);
8+
//~^ ERROR type ascriptions are not
109
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
error: type ascriptions are not allowed in lvalue contexts
2+
--> $DIR/coerce-array-repeat-in-fn-arg.rs:7:8
3+
|
4+
LL | foo([&arr : &[u32]; 3]);
5+
| ^^^^^^^^^^^^^
6+
7+
error: aborting due to previous error
8+

src/test/ui/coercion/type-ascription/coerce-enum-variant.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
// build-pass
2-
31
#![feature(type_ascription)]
42

53
enum Foo<'a> {
@@ -10,4 +8,5 @@ enum Foo<'a> {
108
fn main() {
119
let arr = [4,5,6];
1210
let temp = Foo::A((10, &arr : &[u32]));
11+
//~^ ERROR type ascriptions are not
1312
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
error: type ascriptions are not allowed in lvalue contexts
2+
--> $DIR/coerce-enum-variant.rs:10:26
3+
|
4+
LL | let temp = Foo::A((10, &arr : &[u32]));
5+
| ^^^^^^^^^^^^^
6+
7+
error: aborting due to previous error
8+

src/test/ui/coercion/type-ascription/coerce-struct-fields-pass-in-let-stmt.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
// Here we test for coercions in struct fields of nested type ascriptions
22
// inside a tuple using an unsized coercion and a coercion from &mut -> &
33

4-
// run-pass
5-
64
#![feature(type_ascription)]
75

86
use std::any::type_name;
@@ -26,4 +24,5 @@ fn main() {
2624
let tup = (9, (3, &arr : &[u32]), &mut bar);
2725
assert_eq!(type_of(tup), "(i32, (i32, &[u32]), &mut coerce_struct_fields_pass_in_let_stmt::Bar)");
2826
let _ = Foo { _a : (9, (3, &arr : &[u32]), &mut bar) };
27+
//~^ ERROR type ascriptions are not
2928
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
error: type ascriptions are not allowed in lvalue contexts
2+
--> $DIR/coerce-struct-fields-pass-in-let-stmt.rs:26:30
3+
|
4+
LL | let _ = Foo { _a : (9, (3, &arr : &[u32]), &mut bar) };
5+
| ^^^^^^^^^^^^^
6+
7+
error: aborting due to previous error
8+

src/test/ui/coercion/type-ascription/coerce-to-unsized-in-return-expr.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
// build-pass
2-
31
#![feature(type_ascription)]
42

53
fn foo<'a>(arg : &'a [u32; 3]) -> &'a [u32] {
64
arg : &[u32]
5+
//~^ ERROR type ascriptions are not
76
}
87

98
fn main() {
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
error: type ascriptions are not allowed in lvalue contexts
2+
--> $DIR/coerce-to-unsized-in-return-expr.rs:4:3
3+
|
4+
LL | arg : &[u32]
5+
| ^^^^^^^^^^^^
6+
7+
error: aborting due to previous error
8+

src/test/ui/coercion/type-ascription/coerce-union-field.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
// build-pass
2-
31
#![feature(type_ascription)]
42

53
union Foo<'a> {
@@ -11,4 +9,6 @@ fn main() {
119
let arr = [4,5,6];
1210
let x = &mut 26;
1311
let _ = Foo { f1: (x : &u32, (5, &arr : &[u32])) };
12+
//~^ ERROR type ascriptions
13+
//~^^ ERROR type ascriptions
1414
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
error: type ascriptions are not allowed in lvalue contexts
2+
--> $DIR/coerce-union-field.rs:11:22
3+
|
4+
LL | let _ = Foo { f1: (x : &u32, (5, &arr : &[u32])) };
5+
| ^^^^^^^^
6+
|
7+
help: try to use the type ascription when creating the local variable
8+
|
9+
LL | let x: &u32 = &mut 26;
10+
| ^^^^^^^^^^^
11+
12+
error: type ascriptions are not allowed in lvalue contexts
13+
--> $DIR/coerce-union-field.rs:11:36
14+
|
15+
LL | let _ = Foo { f1: (x : &u32, (5, &arr : &[u32])) };
16+
| ^^^^^^^^^^^^^
17+
18+
error: aborting due to 2 previous errors
19+
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// run-pass
21
// Tests that the result of type ascription has adjustments applied
32

43
#![feature(type_ascription)]
@@ -7,4 +6,5 @@ fn main() {
76
let x = [1, 2, 3];
87
// The RHS should coerce to &[i32]
98
let _y : &[i32] = &x : &[i32; 3];
9+
//~^ ERROR type ascriptions
1010
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
error: type ascriptions are not allowed in lvalue contexts
2+
--> $DIR/mir_ascription_coercion.rs:8:23
3+
|
4+
LL | let _y : &[i32] = &x : &[i32; 3];
5+
| ^^^^^^^^^^^^^^
6+
7+
error: aborting due to previous error
8+

src/test/ui/nll/user-annotations/type_ascription_static_lifetime.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,6 @@
33

44
fn main() {
55
let x = 22_u32;
6-
let y: &u32 = &x: &'static u32; //~ ERROR E0597
6+
let y: &u32 = &x: &'static u32;
7+
//~^ ERROR type ascriptions are not
78
}
Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,8 @@
1-
error[E0597]: `x` does not live long enough
1+
error: type ascriptions are not allowed in lvalue contexts
22
--> $DIR/type_ascription_static_lifetime.rs:6:19
33
|
4-
LL | let y: &u32 = &x: &'static u32;
5-
| ^^--------------
6-
| |
7-
| borrowed value does not live long enough
8-
| type annotation requires that `x` is borrowed for `'static`
9-
LL | }
10-
| - `x` dropped here while still borrowed
4+
LL | let y: &u32 = &x: &'static u32;
5+
| ^^^^^^^^^^^^^^^^
116

127
error: aborting due to previous error
138

14-
For more information about this error, try `rustc --explain E0597`.

0 commit comments

Comments
 (0)