Skip to content

Commit 12d411f

Browse files
committed
add tests
1 parent 9e92015 commit 12d411f

35 files changed

+897
-37
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#![feature(generic_associated_types)]
2+
//~^ WARNING: the feature `generic_associated_types` is incomplete
3+
4+
trait X {
5+
type Y<'x>;
6+
}
7+
8+
fn main() {
9+
fn _f(arg : Box<dyn for<'a> X<Y<'x> = &'a [u32]>>) {}
10+
//~^ ERROR: use of undeclared lifetime name `'x`
11+
//~| ERROR: binding for associated type `Y` references lifetime
12+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
warning: the feature `generic_associated_types` is incomplete and may not be safe to use and/or cause compiler crashes
2+
--> $DIR/gat-in-trait-path-undeclared-lifetime.rs:1:12
3+
|
4+
LL | #![feature(generic_associated_types)]
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^
6+
|
7+
= note: `#[warn(incomplete_features)]` on by default
8+
= note: see issue #44265 <https://github.com/rust-lang/rust/issues/44265> for more information
9+
10+
error[E0261]: use of undeclared lifetime name `'x`
11+
--> $DIR/gat-in-trait-path-undeclared-lifetime.rs:9:35
12+
|
13+
LL | fn _f(arg : Box<dyn for<'a> X<Y<'x> = &'a [u32]>>) {}
14+
| - ^^ undeclared lifetime
15+
| |
16+
| help: consider introducing lifetime `'x` here: `<'x>`
17+
|
18+
= help: if you want to experiment with in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes
19+
20+
error[E0582]: binding for associated type `Y` references lifetime `'a`, which does not appear in the trait input types
21+
--> $DIR/gat-in-trait-path-undeclared-lifetime.rs:9:33
22+
|
23+
LL | fn _f(arg : Box<dyn for<'a> X<Y<'x> = &'a [u32]>>) {}
24+
| ^^^^^^^^^^^^^^^^^
25+
26+
error: aborting due to 2 previous errors; 1 warning emitted
27+
28+
Some errors have detailed explanations: E0261, E0582.
29+
For more information about an error, try `rustc --explain E0261`.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// check-pass
2+
3+
#![feature(generic_associated_types)]
4+
//~^ WARNING: the feature `generic_associated_types` is incomplete
5+
#![feature(associated_type_defaults)]
6+
7+
trait Foo {
8+
type A<'a> where Self: 'a;
9+
}
10+
11+
struct Fooy;
12+
13+
impl Foo for Fooy {
14+
type A<'a> = &'a ();
15+
}
16+
17+
#[derive(Clone)]
18+
struct Fooer<T>(T);
19+
20+
impl<T> Foo for Fooer<T> {
21+
type A<'x> where T: 'x = &'x ();
22+
}
23+
24+
fn f(_arg : Box<dyn for<'a> Foo<A<'a> = &'a ()>>) {}
25+
26+
27+
fn main() {
28+
let foo = Fooer(5);
29+
f(Box::new(foo));
30+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
warning: the feature `generic_associated_types` is incomplete and may not be safe to use and/or cause compiler crashes
2+
--> $DIR/gat-in-trait-path.rs:3:12
3+
|
4+
LL | #![feature(generic_associated_types)]
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^
6+
|
7+
= note: `#[warn(incomplete_features)]` on by default
8+
= note: see issue #44265 <https://github.com/rust-lang/rust/issues/44265> for more information
9+
10+
warning: 1 warning emitted
11+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#![feature(generic_associated_types)]
2+
//~^ WARNING: the feature `generic_associated_types` is incomplete
3+
4+
trait Foo {
5+
type F<'a>;
6+
7+
fn identity<'a>(t: &'a Self::F<'a>) -> &'a Self::F<'a> { t }
8+
}
9+
10+
impl <T, T1> Foo for T {
11+
type F<T1> = &[u8];
12+
//~^ ERROR: the name `T1` is already used for
13+
//~| ERROR: missing lifetime specifier
14+
}
15+
16+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
error[E0403]: the name `T1` is already used for a generic parameter in this item's generic parameters
2+
--> $DIR/gat-trait-path-generic-type-arg.rs:11:12
3+
|
4+
LL | impl <T, T1> Foo for T {
5+
| -- first use of `T1`
6+
LL | type F<T1> = &[u8];
7+
| ^^ already used
8+
9+
warning: the feature `generic_associated_types` is incomplete and may not be safe to use and/or cause compiler crashes
10+
--> $DIR/gat-trait-path-generic-type-arg.rs:1:12
11+
|
12+
LL | #![feature(generic_associated_types)]
13+
| ^^^^^^^^^^^^^^^^^^^^^^^^
14+
|
15+
= note: `#[warn(incomplete_features)]` on by default
16+
= note: see issue #44265 <https://github.com/rust-lang/rust/issues/44265> for more information
17+
18+
error[E0106]: missing lifetime specifier
19+
--> $DIR/gat-trait-path-generic-type-arg.rs:11:18
20+
|
21+
LL | type F<T1> = &[u8];
22+
| ^ expected named lifetime parameter
23+
|
24+
help: consider introducing a named lifetime parameter
25+
|
26+
LL | type F<'a, T1> = &'a [u8];
27+
| ^^^ ^^^
28+
29+
error: aborting due to 2 previous errors; 1 warning emitted
30+
31+
Some errors have detailed explanations: E0106, E0403.
32+
For more information about an error, try `rustc --explain E0106`.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#![feature(generic_associated_types)]
2+
//~^ WARNING: the feature `generic_associated_types` is incomplete
3+
4+
trait X {
5+
type Y<'a>;
6+
//~^ ERROR missing generics for
7+
//~| ERROR missing generics for
8+
9+
fn foo<'a>(t : Self::Y<'a>) -> Self::Y<'a> { t }
10+
}
11+
12+
impl<T> X for T {
13+
fn foo<'a, T1: X<Y = T1>>(t : T1) -> T1::Y<'a> {
14+
t
15+
}
16+
}
17+
18+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
warning: the feature `generic_associated_types` is incomplete and may not be safe to use and/or cause compiler crashes
2+
--> $DIR/gat-trait-path-missing-lifetime.rs:1:12
3+
|
4+
LL | #![feature(generic_associated_types)]
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^
6+
|
7+
= note: `#[warn(incomplete_features)]` on by default
8+
= note: see issue #44265 <https://github.com/rust-lang/rust/issues/44265> for more information
9+
10+
error[E0107]: missing generics for associated type `X::Y`
11+
--> $DIR/gat-trait-path-missing-lifetime.rs:5:8
12+
|
13+
LL | type Y<'a>;
14+
| ^ expected 1 lifetime argument
15+
|
16+
note: associated type defined here, with 1 lifetime parameter: `'a`
17+
--> $DIR/gat-trait-path-missing-lifetime.rs:5:8
18+
|
19+
LL | type Y<'a>;
20+
| ^ --
21+
help: use angle brackets to add missing lifetime argument
22+
|
23+
LL | type Y<'a><'a>;
24+
| ^^^^
25+
26+
error[E0107]: missing generics for associated type `X::Y`
27+
--> $DIR/gat-trait-path-missing-lifetime.rs:5:8
28+
|
29+
LL | type Y<'a>;
30+
| ^ expected 1 lifetime argument
31+
|
32+
note: associated type defined here, with 1 lifetime parameter: `'a`
33+
--> $DIR/gat-trait-path-missing-lifetime.rs:5:8
34+
|
35+
LL | type Y<'a>;
36+
| ^ --
37+
help: use angle brackets to add missing lifetime argument
38+
|
39+
LL | type Y<'a><'a>;
40+
| ^^^^
41+
42+
error: aborting due to 2 previous errors; 1 warning emitted
43+
44+
For more information about this error, try `rustc --explain E0107`.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#![feature(generic_associated_types)]
2+
//~^ WARNING: the feature `generic_associated_types` is incomplete
3+
4+
trait X {
5+
type Y<'a>;
6+
//~^ ERROR this associated type
7+
//~| ERROR this associated type
8+
}
9+
10+
fn foo<'a>(arg: Box<dyn X<Y('a) = &'a ()>>) {}
11+
//~^ ERROR: lifetime in trait object type must be followed by `+`
12+
//~| ERROR: parenthesized generic arguments cannot be used
13+
//~| WARNING: trait objects without an explicit `dyn` are deprecated
14+
15+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
error: lifetime in trait object type must be followed by `+`
2+
--> $DIR/gat-trait-path-parenthesised-args.rs:10:29
3+
|
4+
LL | fn foo<'a>(arg: Box<dyn X<Y('a) = &'a ()>>) {}
5+
| ^^
6+
7+
error: parenthesized generic arguments cannot be used in associated type constraints
8+
--> $DIR/gat-trait-path-parenthesised-args.rs:10:27
9+
|
10+
LL | fn foo<'a>(arg: Box<dyn X<Y('a) = &'a ()>>) {}
11+
| ^^^^^
12+
13+
warning: the feature `generic_associated_types` is incomplete and may not be safe to use and/or cause compiler crashes
14+
--> $DIR/gat-trait-path-parenthesised-args.rs:1:12
15+
|
16+
LL | #![feature(generic_associated_types)]
17+
| ^^^^^^^^^^^^^^^^^^^^^^^^
18+
|
19+
= note: `#[warn(incomplete_features)]` on by default
20+
= note: see issue #44265 <https://github.com/rust-lang/rust/issues/44265> for more information
21+
22+
warning: trait objects without an explicit `dyn` are deprecated
23+
--> $DIR/gat-trait-path-parenthesised-args.rs:10:29
24+
|
25+
LL | fn foo<'a>(arg: Box<dyn X<Y('a) = &'a ()>>) {}
26+
| ^^ help: use `dyn`: `dyn 'a`
27+
|
28+
= note: `#[warn(bare_trait_objects)]` on by default
29+
30+
error[E0107]: this associated type takes 1 lifetime argument but 0 lifetime arguments were supplied
31+
--> $DIR/gat-trait-path-parenthesised-args.rs:5:8
32+
|
33+
LL | type Y<'a>;
34+
| ^ expected 1 lifetime argument
35+
|
36+
note: associated type defined here, with 1 lifetime parameter: `'a`
37+
--> $DIR/gat-trait-path-parenthesised-args.rs:5:8
38+
|
39+
LL | type Y<'a>;
40+
| ^ --
41+
help: add missing lifetime argument
42+
|
43+
LL | fn foo<'a>(arg: Box<dyn X<Y('a'a) = &'a ()>>) {}
44+
| ^^
45+
46+
error[E0107]: this associated type takes 0 type arguments but 1 type argument was supplied
47+
--> $DIR/gat-trait-path-parenthesised-args.rs:5:8
48+
|
49+
LL | type Y<'a>;
50+
| ________^-
51+
| | |
52+
| | expected 0 type arguments
53+
LL | |
54+
LL | |
55+
LL | | }
56+
LL | |
57+
LL | | fn foo<'a>(arg: Box<dyn X<Y('a) = &'a ()>>) {}
58+
| |_________________________________________- help: remove these generics
59+
|
60+
note: associated type defined here, with 0 type parameters
61+
--> $DIR/gat-trait-path-parenthesised-args.rs:5:8
62+
|
63+
LL | type Y<'a>;
64+
| ^
65+
66+
error: aborting due to 4 previous errors; 2 warnings emitted
67+
68+
For more information about this error, try `rustc --explain E0107`.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// check-pass
2+
3+
#![feature(generic_associated_types)]
4+
//~^ WARNING: the feature `generic_associated_types` is incomplete
5+
6+
trait X {
7+
type Y<'a>;
8+
}
9+
10+
fn _func1<'a>(_x: Box<dyn X<Y<'a>=&'a ()>>) {}
11+
12+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
warning: the feature `generic_associated_types` is incomplete and may not be safe to use and/or cause compiler crashes
2+
--> $DIR/issue-67510-pass.rs:3:12
3+
|
4+
LL | #![feature(generic_associated_types)]
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^
6+
|
7+
= note: `#[warn(incomplete_features)]` on by default
8+
= note: see issue #44265 <https://github.com/rust-lang/rust/issues/44265> for more information
9+
10+
warning: 1 warning emitted
11+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
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 f(x: Box<dyn X<Y<'a>=&'a ()>>) {}
9+
//~^ ERROR: use of undeclared lifetime name `'a`
10+
//~| ERROR: use of undeclared lifetime name `'a`
11+
12+
13+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
warning: the feature `generic_associated_types` is incomplete and may not be safe to use and/or cause compiler crashes
2+
--> $DIR/issue-67510.rs:1:12
3+
|
4+
LL | #![feature(generic_associated_types)]
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^
6+
|
7+
= note: `#[warn(incomplete_features)]` on by default
8+
= note: see issue #44265 <https://github.com/rust-lang/rust/issues/44265> for more information
9+
10+
error[E0261]: use of undeclared lifetime name `'a`
11+
--> $DIR/issue-67510.rs:8:21
12+
|
13+
LL | fn f(x: Box<dyn X<Y<'a>=&'a ()>>) {}
14+
| - ^^ undeclared lifetime
15+
| |
16+
| help: consider introducing lifetime `'a` here: `<'a>`
17+
|
18+
= help: if you want to experiment with in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes
19+
20+
error[E0261]: use of undeclared lifetime name `'a`
21+
--> $DIR/issue-67510.rs:8:26
22+
|
23+
LL | fn f(x: Box<dyn X<Y<'a>=&'a ()>>) {}
24+
| - ^^ undeclared lifetime
25+
| |
26+
| help: consider introducing lifetime `'a` here: `<'a>`
27+
|
28+
= help: if you want to experiment with in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes
29+
30+
error: aborting due to 2 previous errors; 1 warning emitted
31+
32+
For more information about this error, try `rustc --explain E0261`.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// check-pass
2+
3+
#![feature(generic_associated_types)]
4+
//~^ WARNING: the feature `generic_associated_types` is incomplete
5+
6+
7+
trait Fun {
8+
type F<'a>;
9+
10+
fn identity<'a>(t: Self::F<'a>) -> Self::F<'a> { t }
11+
}
12+
13+
impl <T> Fun for T {
14+
type F<'a> = Self;
15+
}
16+
17+
fn bug<'a, T: for<'b> Fun<F<'b> = T>>(t: T) -> T::F<'a> {
18+
T::identity(t)
19+
}
20+
21+
22+
fn main() {
23+
let x = 10;
24+
25+
bug(x);
26+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
warning: the feature `generic_associated_types` is incomplete and may not be safe to use and/or cause compiler crashes
2+
--> $DIR/issue-68648-1.rs:3:12
3+
|
4+
LL | #![feature(generic_associated_types)]
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^
6+
|
7+
= note: `#[warn(incomplete_features)]` on by default
8+
= note: see issue #44265 <https://github.com/rust-lang/rust/issues/44265> for more information
9+
10+
warning: 1 warning emitted
11+

0 commit comments

Comments
 (0)