Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 5c4568d

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

35 files changed

+346
-32
lines changed
Lines changed: 11 additions & 0 deletions
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() {}
Lines changed: 17 additions & 0 deletions
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+
Lines changed: 23 additions & 0 deletions
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() {}
Lines changed: 25 additions & 0 deletions
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+
Lines changed: 21 additions & 0 deletions
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() {}
Lines changed: 50 additions & 0 deletions
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`.
Lines changed: 35 additions & 0 deletions
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() {}
Lines changed: 31 additions & 0 deletions
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+
Lines changed: 10 additions & 0 deletions
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+
};
Lines changed: 8 additions & 0 deletions
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+

0 commit comments

Comments
 (0)