Skip to content

Commit 5ddad99

Browse files
committed
add and update tests
1 parent 728d257 commit 5ddad99

14 files changed

+141
-38
lines changed

src/test/ui/generic-associated-types/parse/trait-path-expected-token.stderr

+3-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@ error: expected one of `!`, `(`, `+`, `,`, `::`, `<`, or `>`, found `=`
22
--> $DIR/trait-path-expected-token.rs:8:33
33
|
44
LL | fn f1<'a>(arg : Box<dyn X<Y = B = &'a ()>>) {}
5-
| ^ expected one of 7 possible tokens
5+
| - ^ expected one of 7 possible tokens
6+
| |
7+
| maybe try to close unmatched angle bracket
68

79
warning: the feature `generic_associated_types` is incomplete and may not be safe to use and/or cause compiler crashes
810
--> $DIR/trait-path-expected-token.rs:1:12

src/test/ui/generic-associated-types/parse/trait-path-expressions.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ mod error2 {
1717
}
1818

1919
fn f2<'a>(arg : Box<dyn X< { 1 } = 32 >>) {}
20-
//~^ ERROR: only types can be used in associated type constraints
20+
//~^ ERROR: expected one of
2121
}
2222

2323
fn main() {}

src/test/ui/generic-associated-types/parse/trait-path-expressions.stderr

+5-3
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,13 @@ LL | fn f1<'a>(arg : Box<dyn X< 1 = 32 >>) {}
66
| |
77
| while parsing a const generic argument starting here
88

9-
error: only types can be used in associated type constraints
10-
--> $DIR/trait-path-expressions.rs:19:30
9+
error: expected one of `,`, `:`, or `>`, found `=`
10+
--> $DIR/trait-path-expressions.rs:19:36
1111
|
1212
LL | fn f2<'a>(arg : Box<dyn X< { 1 } = 32 >>) {}
13-
| ^^^^^
13+
| - ^ expected one of `,`, `:`, or `>`
14+
| |
15+
| maybe try to close unmatched angle bracket
1416

1517
warning: the feature `generic_associated_types` is incomplete and may not be safe to use and/or cause compiler crashes
1618
--> $DIR/trait-path-expressions.rs:1:12

src/test/ui/generic-associated-types/parse/trait-path-missing-gen_arg.stderr

+3-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@ error: expected one of `>`, a const expression, lifetime, or type, found `=`
2828
--> $DIR/trait-path-missing-gen_arg.rs:17:30
2929
|
3030
LL | fn f1<'a>(arg : Box<dyn X< = 32 >>) {}
31-
| ^ expected one of `>`, a const expression, lifetime, or type
31+
| - ^ expected one of `>`, const, lifetime, or type
32+
| |
33+
| maybe try to close unmatched angle bracket
3234

3335
warning: the feature `generic_associated_types` is incomplete and may not be safe to use and/or cause compiler crashes
3436
--> $DIR/trait-path-missing-gen_arg.rs:1:12

src/test/ui/generic-associated-types/parse/trait-path-segments.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const _: () = {
77
}
88

99
fn f1<'a>(arg : Box<dyn X<X::Y = u32>>) {}
10-
//~^ ERROR: paths with multiple segments cannot be used in associated type constraints
10+
//~^ ERROR: expected one of
1111
};
1212

1313
const _: () = {
@@ -18,7 +18,7 @@ const _: () = {
1818
trait Z {}
1919

2020
impl<T : X<<Self as X>::Y<'a> = &'a u32>> Z for T {}
21-
//~^ ERROR: qualified paths cannot be used in associated type constraints
21+
//~^ ERROR: expected one of
2222
};
2323

2424
const _: () = {
@@ -29,7 +29,7 @@ const _: () = {
2929
trait Z {}
3030

3131
impl<T : X<X::Y<'a> = &'a u32>> Z for T {}
32-
//~^ ERROR: paths with multiple segments cannot be used in associated type constraints
32+
//~^ ERROR: expected one of
3333
};
3434

3535
fn main() {}

src/test/ui/generic-associated-types/parse/trait-path-segments.stderr

+15-11
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,26 @@
1-
error: paths with multiple segments cannot be used in associated type constraints
2-
--> $DIR/trait-path-segments.rs:9:31
1+
error: expected one of `!`, `(`, `+`, `,`, `::`, `:`, `<`, or `>`, found `=`
2+
--> $DIR/trait-path-segments.rs:9:36
33
|
44
LL | fn f1<'a>(arg : Box<dyn X<X::Y = u32>>) {}
5-
| ^^^^
5+
| - ^ expected one of 8 possible tokens
6+
| |
7+
| maybe try to close unmatched angle bracket
68

7-
error: qualified paths cannot be used in associated type constraints
8-
--> $DIR/trait-path-segments.rs:20:16
9+
error: expected one of `,`, `::`, `:`, or `>`, found `=`
10+
--> $DIR/trait-path-segments.rs:20:35
911
|
1012
LL | impl<T : X<<Self as X>::Y<'a> = &'a u32>> Z for T {}
11-
| ^^^^^^^^^-^^^^^^^^
12-
| |
13-
| not allowed in associated type constraints
13+
| - ^ expected one of `,`, `::`, `:`, or `>`
14+
| |
15+
| maybe try to close unmatched angle bracket
1416

15-
error: paths with multiple segments cannot be used in associated type constraints
16-
--> $DIR/trait-path-segments.rs:31:16
17+
error: expected one of `!`, `+`, `,`, `::`, `:`, or `>`, found `=`
18+
--> $DIR/trait-path-segments.rs:31:25
1719
|
1820
LL | impl<T : X<X::Y<'a> = &'a u32>> Z for T {}
19-
| ^^^^^^^^
21+
| - ^ expected one of `!`, `+`, `,`, `::`, `:`, or `>`
22+
| |
23+
| maybe try to close unmatched angle bracket
2024

2125
warning: the feature `generic_associated_types` is incomplete and may not be safe to use and/or cause compiler crashes
2226
--> $DIR/trait-path-segments.rs:1:12

src/test/ui/generic-associated-types/parse/trait-path-types.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,17 @@ trait X {
77

88
const _: () = {
99
fn f<'a>(arg : Box<dyn X< [u8; 1] = u32>>) {}
10-
//~^ ERROR: only path types can be used in associated type constraints
10+
//~^ ERROR: expected one of
1111
};
1212

1313
const _: () = {
1414
fn f1<'a>(arg : Box<dyn X<(Y<'a>) = &'a ()>>) {}
15-
//~^ ERROR: only path types can be used in associated type constraints
15+
//~^ ERROR: expected one of
1616
};
1717

1818
const _: () = {
1919
fn f1<'a>(arg : Box<dyn X< 'a = u32 >>) {}
20-
//~^ ERROR: only types can be used in associated type constraints
20+
//~^ ERROR: expected one of
2121
};
2222

2323
fn main() {}

src/test/ui/generic-associated-types/parse/trait-path-types.stderr

+15-9
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,26 @@
1-
error: only path types can be used in associated type constraints
2-
--> $DIR/trait-path-types.rs:9:29
1+
error: expected one of `,`, `:`, or `>`, found `=`
2+
--> $DIR/trait-path-types.rs:9:37
33
|
44
LL | fn f<'a>(arg : Box<dyn X< [u8; 1] = u32>>) {}
5-
| ^^^^^^^
5+
| - ^ expected one of `,`, `:`, or `>`
6+
| |
7+
| maybe try to close unmatched angle bracket
68

7-
error: only path types can be used in associated type constraints
8-
--> $DIR/trait-path-types.rs:14:29
9+
error: expected one of `,`, `:`, or `>`, found `=`
10+
--> $DIR/trait-path-types.rs:14:37
911
|
1012
LL | fn f1<'a>(arg : Box<dyn X<(Y<'a>) = &'a ()>>) {}
11-
| ^^^^^^^
13+
| - ^ expected one of `,`, `:`, or `>`
14+
| |
15+
| maybe try to close unmatched angle bracket
1216

13-
error: only types can be used in associated type constraints
14-
--> $DIR/trait-path-types.rs:19:30
17+
error: expected one of `,`, `:`, or `>`, found `=`
18+
--> $DIR/trait-path-types.rs:19:33
1519
|
1620
LL | fn f1<'a>(arg : Box<dyn X< 'a = u32 >>) {}
17-
| ^^
21+
| -- ^ expected one of `,`, `:`, or `>`
22+
| |
23+
| maybe try to close unmatched angle bracket
1824

1925
warning: the feature `generic_associated_types` is incomplete and may not be safe to use and/or cause compiler crashes
2026
--> $DIR/trait-path-types.rs:1:12

src/test/ui/issues/issue-34334.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
fn main () {
22
let sr: Vec<(u32, _, _) = vec![];
3-
//~^ ERROR only path types can be used in associated type constraints
3+
//~^ ERROR expected one of
4+
45
let sr2: Vec<(u32, _, _)> = sr.iter().map(|(faction, th_sender, th_receiver)| {}).collect();
56
//~^ ERROR a value of type `Vec<(u32, _, _)>` cannot be built
7+
68
}

src/test/ui/issues/issue-34334.stderr

+6-5
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
1-
error: only path types can be used in associated type constraints
2-
--> $DIR/issue-34334.rs:2:17
1+
error: expected one of `,`, `:`, or `>`, found `=`
2+
--> $DIR/issue-34334.rs:2:29
33
|
44
LL | let sr: Vec<(u32, _, _) = vec![];
5-
| -- ^^^^^^^^^^^
6-
| |
5+
| -- - ^ expected one of `,`, `:`, or `>`
6+
| | |
7+
| | maybe try to close unmatched angle bracket
78
| while parsing the type for `sr`
89

910
error[E0277]: a value of type `Vec<(u32, _, _)>` cannot be built from an iterator over elements of type `()`
10-
--> $DIR/issue-34334.rs:4:87
11+
--> $DIR/issue-34334.rs:5:87
1112
|
1213
LL | let sr2: Vec<(u32, _, _)> = sr.iter().map(|(faction, th_sender, th_receiver)| {}).collect();
1314
| ^^^^^^^ value of type `Vec<(u32, _, _)>` cannot be built from `std::iter::Iterator<Item=()>`
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
struct Foo<T1, T2> {
2+
_a : T1,
3+
_b : T2,
4+
}
5+
6+
fn test1<T>(arg : T) {
7+
let v : Vec<(u32,_) = vec![];
8+
//~^ ERROR: expected one of
9+
//~| ERROR: type annotations needed
10+
}
11+
12+
fn test2<T1, T2>(arg1 : T1, arg2 : T2) {
13+
let foo : Foo::<T1, T2 = Foo {_a : arg1, _b : arg2};
14+
//~^ ERROR: expected one of
15+
}
16+
17+
fn test3<'a>(arg : &'a u32) {
18+
let v : Vec<'a = vec![];
19+
//~^ ERROR: expected one of
20+
//~| ERROR: type annotations needed for `Vec<T>`
21+
}
22+
23+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
error: expected one of `,`, `:`, or `>`, found `=`
2+
--> $DIR/missing-closing-angle-bracket-eq-constraint.rs:7:23
3+
|
4+
LL | let v : Vec<(u32,_) = vec![];
5+
| - - ^ expected one of `,`, `:`, or `>`
6+
| | |
7+
| | maybe try to close unmatched angle bracket
8+
| while parsing the type for `v`
9+
10+
error: expected one of `!`, `(`, `+`, `,`, `::`, `<`, or `>`, found `{`
11+
--> $DIR/missing-closing-angle-bracket-eq-constraint.rs:13:32
12+
|
13+
LL | let foo : Foo::<T1, T2 = Foo {_a : arg1, _b : arg2};
14+
| --- ^ expected one of 7 possible tokens
15+
| |
16+
| while parsing the type for `foo`
17+
18+
error: expected one of `,`, `:`, or `>`, found `=`
19+
--> $DIR/missing-closing-angle-bracket-eq-constraint.rs:18:18
20+
|
21+
LL | let v : Vec<'a = vec![];
22+
| - -- ^ expected one of `,`, `:`, or `>`
23+
| | |
24+
| | maybe try to close unmatched angle bracket
25+
| while parsing the type for `v`
26+
27+
error[E0282]: type annotations needed for `Vec<T>`
28+
--> $DIR/missing-closing-angle-bracket-eq-constraint.rs:7:25
29+
|
30+
LL | let v : Vec<(u32,_) = vec![];
31+
| - ^^^^^^ cannot infer type for type parameter `T`
32+
| |
33+
| consider giving `v` the explicit type `Vec<T>`, where the type parameter `T` is specified
34+
|
35+
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
36+
37+
error[E0282]: type annotations needed for `Vec<T>`
38+
--> $DIR/missing-closing-angle-bracket-eq-constraint.rs:18:20
39+
|
40+
LL | let v : Vec<'a = vec![];
41+
| - ^^^^^^ cannot infer type for type parameter `T`
42+
| |
43+
| consider giving `v` the explicit type `Vec<T>`, where the type parameter `T` is specified
44+
|
45+
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
46+
47+
error: aborting due to 5 previous errors
48+
49+
For more information about this error, try `rustc --explain E0282`.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
fn main() {
2+
let v : Vec::<Vec<(u32,_,_)> = vec![vec![]];
3+
//~^ ERROR: expected one of
4+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
error: expected one of `,` or `>`, found `;`
2+
--> $DIR/nested-missing-closing-angle-bracket.rs:2:46
3+
|
4+
LL | let v : Vec::<Vec<(u32,_,_)> = vec![vec![]];
5+
| - while parsing the type for `v` ^ expected one of `,` or `>`
6+
7+
error: aborting due to previous error
8+

0 commit comments

Comments
 (0)