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+

0 commit comments

Comments
 (0)