Skip to content

Commit 5c4568d

Browse files
b-naberb-naber
b-naber
authored and
b-naber
committed
add tests
1 parent 37d103f commit 5c4568d

35 files changed

+346
-32
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#![feature(generic_associated_types)]
2+
//~^ WARNING: the feature `generic_associated_types` is incomplete
3+
4+
trait X {
5+
type Y<'a>;
6+
}
7+
8+
fn f1<'a>(arg : Box<dyn X<Y = B = &'a ()>>) {}
9+
//~^ ERROR: expected one of `!`, `(`, `+`, `,`, `::`, `<`, or `>`, found `=`
10+
11+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
error: expected one of `!`, `(`, `+`, `,`, `::`, `<`, or `>`, found `=`
2+
--> $DIR/trait-path-expected-token.rs:8:33
3+
|
4+
LL | fn f1<'a>(arg : Box<dyn X<Y = B = &'a ()>>) {}
5+
| ^ expected one of 7 possible tokens
6+
7+
warning: the feature `generic_associated_types` is incomplete and may not be safe to use and/or cause compiler crashes
8+
--> $DIR/trait-path-expected-token.rs:1:12
9+
|
10+
LL | #![feature(generic_associated_types)]
11+
| ^^^^^^^^^^^^^^^^^^^^^^^^
12+
|
13+
= note: `#[warn(incomplete_features)]` on by default
14+
= note: see issue #44265 <https://github.com/rust-lang/rust/issues/44265> for more information
15+
16+
error: aborting due to previous error; 1 warning emitted
17+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#![feature(generic_associated_types)]
2+
//~^ WARNING: the feature `generic_associated_types` is incomplete
3+
4+
mod error1 {
5+
trait X {
6+
type Y<'a>;
7+
}
8+
9+
fn f1<'a>(arg : Box<dyn X< 1 = 32 >>) {}
10+
//~^ ERROR: expected expression, found `)`
11+
}
12+
13+
mod error2 {
14+
15+
trait X {
16+
type Y<'a>;
17+
}
18+
19+
fn f2<'a>(arg : Box<dyn X< { 1 } = 32 >>) {}
20+
//~^ ERROR: only types can be used in associated type constraints
21+
}
22+
23+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
error: expected expression, found `)`
2+
--> $DIR/trait-path-expressions.rs:9:39
3+
|
4+
LL | fn f1<'a>(arg : Box<dyn X< 1 = 32 >>) {}
5+
| - ^ expected expression
6+
| |
7+
| while parsing a const generic argument starting here
8+
9+
error: only types can be used in associated type constraints
10+
--> $DIR/trait-path-expressions.rs:19:30
11+
|
12+
LL | fn f2<'a>(arg : Box<dyn X< { 1 } = 32 >>) {}
13+
| ^^^^^
14+
15+
warning: the feature `generic_associated_types` is incomplete and may not be safe to use and/or cause compiler crashes
16+
--> $DIR/trait-path-expressions.rs:1:12
17+
|
18+
LL | #![feature(generic_associated_types)]
19+
| ^^^^^^^^^^^^^^^^^^^^^^^^
20+
|
21+
= note: `#[warn(incomplete_features)]` on by default
22+
= note: see issue #44265 <https://github.com/rust-lang/rust/issues/44265> for more information
23+
24+
error: aborting due to 2 previous errors; 1 warning emitted
25+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#![feature(generic_associated_types)]
2+
//~^ WARNING: the feature `generic_associated_types` is incomplete
3+
4+
trait X {
5+
type Y<'a>;
6+
}
7+
8+
const _: () = {
9+
fn f1<'a>(arg : Box<dyn X< : 32 >>) {}
10+
//~^ ERROR: expected one of `>`, const, lifetime, or type, found `:`
11+
//~| ERROR: expected parameter name, found `>`
12+
//~| ERROR: expected one of `!`, `)`, `+`, `,`, or `::`, found `>`
13+
//~| ERROR: constant provided when a type was expected
14+
};
15+
16+
const _: () = {
17+
fn f1<'a>(arg : Box<dyn X< = 32 >>) {}
18+
//~^ ERROR: expected one of `>`, const, lifetime, or type, found `=`
19+
};
20+
21+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
error: expected one of `>`, const, lifetime, or type, found `:`
2+
--> $DIR/trait-path-missing-gen_arg.rs:9:30
3+
|
4+
LL | fn f1<'a>(arg : Box<dyn X< : 32 >>) {}
5+
| ^ expected one of `>`, const, lifetime, or type
6+
|
7+
help: expressions must be enclosed in braces to be used as const generic arguments
8+
|
9+
LL | fn f1<'a>(arg : Box<{ dyn X< : 32 } >>) {}
10+
| ^ ^
11+
12+
error: expected parameter name, found `>`
13+
--> $DIR/trait-path-missing-gen_arg.rs:9:36
14+
|
15+
LL | fn f1<'a>(arg : Box<dyn X< : 32 >>) {}
16+
| ^ expected parameter name
17+
18+
error: expected one of `!`, `)`, `+`, `,`, or `::`, found `>`
19+
--> $DIR/trait-path-missing-gen_arg.rs:9:36
20+
|
21+
LL | fn f1<'a>(arg : Box<dyn X< : 32 >>) {}
22+
| ^
23+
| |
24+
| expected one of `!`, `)`, `+`, `,`, or `::`
25+
| help: missing `,`
26+
27+
error: expected one of `>`, const, lifetime, or type, found `=`
28+
--> $DIR/trait-path-missing-gen_arg.rs:17:30
29+
|
30+
LL | fn f1<'a>(arg : Box<dyn X< = 32 >>) {}
31+
| ^ expected one of `>`, const, lifetime, or type
32+
33+
warning: the feature `generic_associated_types` is incomplete and may not be safe to use and/or cause compiler crashes
34+
--> $DIR/trait-path-missing-gen_arg.rs:1:12
35+
|
36+
LL | #![feature(generic_associated_types)]
37+
| ^^^^^^^^^^^^^^^^^^^^^^^^
38+
|
39+
= note: `#[warn(incomplete_features)]` on by default
40+
= note: see issue #44265 <https://github.com/rust-lang/rust/issues/44265> for more information
41+
42+
error[E0747]: constant provided when a type was expected
43+
--> $DIR/trait-path-missing-gen_arg.rs:9:23
44+
|
45+
LL | fn f1<'a>(arg : Box<dyn X< : 32 >>) {}
46+
| ^^^^^^^^^^^
47+
48+
error: aborting due to 5 previous errors; 1 warning emitted
49+
50+
For more information about this error, try `rustc --explain E0747`.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#![feature(generic_associated_types)]
2+
//~^ WARNING: the feature `generic_associated_types` is incomplete
3+
4+
const _: () = {
5+
trait X {
6+
type Y<'a>;
7+
}
8+
9+
fn f1<'a>(arg : Box<dyn X<X::Y = u32>>) {}
10+
//~^ ERROR: paths with multiple segments cannot be used in associated type constraints
11+
};
12+
13+
const _: () = {
14+
trait X {
15+
type Y<'a>;
16+
}
17+
18+
trait Z {}
19+
20+
impl<T : X<<Self as X>::Y<'a> = &'a u32>> Z for T {}
21+
//~^ ERROR: qualified paths cannot be used in associated type constraints
22+
};
23+
24+
const _: () = {
25+
trait X {
26+
type Y<'a>;
27+
}
28+
29+
trait Z {}
30+
31+
impl<T : X<X::Y<'a> = &'a u32>> Z for T {}
32+
//~^ ERROR: paths with multiple segments cannot be used in associated type constraints
33+
};
34+
35+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
error: paths with multiple segments cannot be used in associated type constraints
2+
--> $DIR/trait-path-segments.rs:9:31
3+
|
4+
LL | fn f1<'a>(arg : Box<dyn X<X::Y = u32>>) {}
5+
| ^^^^
6+
7+
error: qualified paths cannot be used in associated type constraints
8+
--> $DIR/trait-path-segments.rs:20:16
9+
|
10+
LL | impl<T : X<<Self as X>::Y<'a> = &'a u32>> Z for T {}
11+
| ^^^^^^^^^-^^^^^^^^
12+
| |
13+
| not allowed in associated type constraints
14+
15+
error: paths with multiple segments cannot be used in associated type constraints
16+
--> $DIR/trait-path-segments.rs:31:16
17+
|
18+
LL | impl<T : X<X::Y<'a> = &'a u32>> Z for T {}
19+
| ^^^^^^^^
20+
21+
warning: the feature `generic_associated_types` is incomplete and may not be safe to use and/or cause compiler crashes
22+
--> $DIR/trait-path-segments.rs:1:12
23+
|
24+
LL | #![feature(generic_associated_types)]
25+
| ^^^^^^^^^^^^^^^^^^^^^^^^
26+
|
27+
= note: `#[warn(incomplete_features)]` on by default
28+
= note: see issue #44265 <https://github.com/rust-lang/rust/issues/44265> for more information
29+
30+
error: aborting due to 3 previous errors; 1 warning emitted
31+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#![feature(generic_associated_types)]
2+
3+
trait X {
4+
type Y<'a>;
5+
}
6+
7+
const _: () = {
8+
fn f2<'a>(arg : Box<dyn X<Y<1> = &'a ()>>) {}
9+
//~^ ERROR: generic associated types in trait paths are currently not implemented
10+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
error: generic associated types in trait paths are currently not implemented
2+
--> $DIR/trait-path-type-error-once-implemented.rs:8:30
3+
|
4+
LL | fn f2<'a>(arg : Box<dyn X<Y<1> = &'a ()>>) {}
5+
| ^^^
6+
7+
error: aborting due to previous error
8+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#![feature(generic_associated_types)]
2+
//~^ WARNING: the feature `generic_associated_types` is incomplete
3+
4+
trait X {
5+
type Y<'a>;
6+
}
7+
8+
const _: () = {
9+
fn f<'a>(arg : Box<dyn X< [u8; 1] = u32>>) {}
10+
//~^ ERROR: only path types can be used in associated type constraints
11+
};
12+
13+
const _: () = {
14+
fn f1<'a>(arg : Box<dyn X<(Y<'a>) = &'a ()>>) {}
15+
//~^ ERROR: only path types can be used in associated type constraints
16+
};
17+
18+
const _: () = {
19+
fn f1<'a>(arg : Box<dyn X< 'a = u32 >>) {}
20+
//~^ ERROR: only types can be used in associated type constraints
21+
};
22+
23+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
error: only path types can be used in associated type constraints
2+
--> $DIR/trait-path-types.rs:9:29
3+
|
4+
LL | fn f<'a>(arg : Box<dyn X< [u8; 1] = u32>>) {}
5+
| ^^^^^^^
6+
7+
error: only path types can be used in associated type constraints
8+
--> $DIR/trait-path-types.rs:14:29
9+
|
10+
LL | fn f1<'a>(arg : Box<dyn X<(Y<'a>) = &'a ()>>) {}
11+
| ^^^^^^^
12+
13+
error: only types can be used in associated type constraints
14+
--> $DIR/trait-path-types.rs:19:30
15+
|
16+
LL | fn f1<'a>(arg : Box<dyn X< 'a = u32 >>) {}
17+
| ^^
18+
19+
warning: the feature `generic_associated_types` is incomplete and may not be safe to use and/or cause compiler crashes
20+
--> $DIR/trait-path-types.rs:1:12
21+
|
22+
LL | #![feature(generic_associated_types)]
23+
| ^^^^^^^^^^^^^^^^^^^^^^^^
24+
|
25+
= note: `#[warn(incomplete_features)]` on by default
26+
= note: see issue #44265 <https://github.com/rust-lang/rust/issues/44265> for more information
27+
28+
error: aborting due to 3 previous errors; 1 warning emitted
29+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#![feature(generic_associated_types)]
2+
3+
trait X {
4+
type Y<'a>;
5+
}
6+
7+
const _: () = {
8+
fn f1<'a>(arg : Box<dyn X<Y<'a> = &'a ()>>) {}
9+
//~^ ERROR: generic associated types in trait paths are currently not implemented
10+
};
11+
12+
const _: () = {
13+
fn f1<'a>(arg : Box<dyn X<Y('a) = &'a ()>>) {}
14+
//~^ ERROR: lifetime in trait object type must be followed by `+`
15+
};
16+
17+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
error: lifetime in trait object type must be followed by `+`
2+
--> $DIR/trait-path-unimplemented.rs:13:31
3+
|
4+
LL | fn f1<'a>(arg : Box<dyn X<Y('a) = &'a ()>>) {}
5+
| ^^
6+
7+
error: generic associated types in trait paths are currently not implemented
8+
--> $DIR/trait-path-unimplemented.rs:8:30
9+
|
10+
LL | fn f1<'a>(arg : Box<dyn X<Y<'a> = &'a ()>>) {}
11+
| ^^^^
12+
13+
error: aborting due to 2 previous errors
14+

src/test/ui/issues/issue-20616-2.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ type Type_1_<'a, T> = &'a T;
99
//type Type_1<'a T> = &'a T; // error: expected `,` or `>` after lifetime name, found `T`
1010

1111

12-
type Type_2 = Type_1_<'static ()>; //~ error: expected one of `,` or `>`, found `(`
12+
type Type_2 = Type_1_<'static ()>; //~ error: expected one of `,`, `:`, `=`, or `>`, found `(`
1313

1414

1515
//type Type_3<T> = Box<T,,>; // error: expected type, found `,`
+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
error: expected one of `,` or `>`, found `(`
1+
error: expected one of `,`, `:`, `=`, or `>`, found `(`
22
--> $DIR/issue-20616-2.rs:12:31
33
|
44
LL | type Type_2 = Type_1_<'static ()>;
5-
| ^ expected one of `,` or `>`
5+
| ^ expected one of `,`, `:`, `=`, or `>`
66

77
error: aborting due to previous error
88

src/test/ui/issues/issue-20616-3.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ type Type_1_<'a, T> = &'a T;
1111

1212

1313
type Type_3<T> = Box<T,,>;
14-
//~^ error: expected one of `>`, const, identifier, lifetime, or type, found `,`
14+
//~^ error: expected one of `>`, const, lifetime, or type, found `,`
1515

1616

1717
//type Type_4<T> = Type_1_<'static,, T>; // error: expected type, found `,`
+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
error: expected one of `>`, const, identifier, lifetime, or type, found `,`
1+
error: expected one of `>`, const, lifetime, or type, found `,`
22
--> $DIR/issue-20616-3.rs:13:24
33
|
44
LL | type Type_3<T> = Box<T,,>;
5-
| ^ expected one of `>`, const, identifier, lifetime, or type
5+
| ^ expected one of `>`, const, lifetime, or type
66

77
error: aborting due to previous error
88

src/test/ui/issues/issue-20616-4.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ type Type_1_<'a, T> = &'a T;
1414

1515

1616
type Type_4<T> = Type_1_<'static,, T>;
17-
//~^ error: expected one of `>`, const, identifier, lifetime, or type, found `,`
17+
//~^ error: expected one of `>`, const, lifetime, or type, found `,`
1818

1919

2020
type Type_5_<'a> = Type_1_<'a, ()>;
+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
error: expected one of `>`, const, identifier, lifetime, or type, found `,`
1+
error: expected one of `>`, const, lifetime, or type, found `,`
22
--> $DIR/issue-20616-4.rs:16:34
33
|
44
LL | type Type_4<T> = Type_1_<'static,, T>;
5-
| ^ expected one of `>`, const, identifier, lifetime, or type
5+
| ^ expected one of `>`, const, lifetime, or type
66

77
error: aborting due to previous error
88

src/test/ui/issues/issue-20616-5.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ type Type_5_<'a> = Type_1_<'a, ()>;
2020

2121

2222
type Type_5<'a> = Type_1_<'a, (),,>;
23-
//~^ error: expected one of `>`, const, identifier, lifetime, or type, found `,`
23+
//~^ error: expected one of `>`, const, lifetime, or type, found `,`
2424

2525

2626
//type Type_6 = Type_5_<'a,,>; // error: expected type, found `,`

0 commit comments

Comments
 (0)