Skip to content

Commit 2654c1a

Browse files
committed
Add TAIT variant of the tests
1 parent 16dc78c commit 2654c1a

File tree

2 files changed

+101
-8
lines changed

2 files changed

+101
-8
lines changed

tests/ui/traits/next-solver/opaques/stranded_opaque.rs

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
//@ compile-flags: -Znext-solver
2+
#![feature(type_alias_impl_trait)]
3+
use std::future::Future;
24

35
// Test for https://github.com/rust-lang/trait-system-refactor-initiative/issues/235
46

57
// These are cases where an opaque types become "stranded" due to
68
// some errors. Make sure we don't ICE in either case.
79

810
// Case 1: `impl Send` is stranded
9-
use std::future::Future;
10-
1111
fn foo() -> impl ?Future<Output = impl Send> {
1212
//~^ ERROR bound modifier `?` can only be applied to `Sized`
1313
//~| ERROR bound modifier `?` can only be applied to `Sized`
@@ -30,4 +30,21 @@ fn ill_formed_string() -> String<impl Trait> {
3030
String::from("a string")
3131
}
3232

33+
// Case 4: TAIT variant of Case 1 to 3
34+
type Foo = impl ?Future<Output = impl Send>;
35+
//~^ ERROR unconstrained opaque type
36+
//~| ERROR unconstrained opaque type
37+
//~| ERROR bound modifier `?` can only be applied to `Sized`
38+
//~| ERROR bound modifier `?` can only be applied to `Sized`
39+
40+
type Produce = impl Trait<Assoc = impl Trait>;
41+
//~^ ERROR unconstrained opaque type
42+
//~| ERROR unconstrained opaque type
43+
//~| ERROR associated type `Assoc` not found for `Trait`
44+
//~| ERROR associated type `Assoc` not found for `Trait`
45+
46+
type IllFormedString = String<impl Trait>;
47+
//~^ ERROR unconstrained opaque type
48+
//~| ERROR struct takes 0 generic arguments but 1 generic argument was supplied
49+
3350
fn main() {}
Lines changed: 82 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,116 @@
11
error: bound modifier `?` can only be applied to `Sized`
2-
--> $DIR/stranded_opaque.rs:11:18
2+
--> $DIR/stranded_opaque.rs:12:18
33
|
44
LL | fn foo() -> impl ?Future<Output = impl Send> {
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
66

77
error[E0220]: associated type `Assoc` not found for `Trait`
8-
--> $DIR/stranded_opaque.rs:21:28
8+
--> $DIR/stranded_opaque.rs:22:28
99
|
1010
LL | fn produce() -> impl Trait<Assoc = impl Trait> {
1111
| ^^^^^ associated type `Assoc` not found
1212

1313
error[E0107]: struct takes 0 generic arguments but 1 generic argument was supplied
14-
--> $DIR/stranded_opaque.rs:28:27
14+
--> $DIR/stranded_opaque.rs:29:27
1515
|
1616
LL | fn ill_formed_string() -> String<impl Trait> {
1717
| ^^^^^^------------ help: remove the unnecessary generics
1818
| |
1919
| expected 0 generic arguments
2020

21+
error[E0107]: struct takes 0 generic arguments but 1 generic argument was supplied
22+
--> $DIR/stranded_opaque.rs:48:25
23+
|
24+
LL | type IllFormedString = String<impl Trait>;
25+
| ^^^^^^------------ help: remove the unnecessary generics
26+
| |
27+
| expected 0 generic arguments
28+
2129
error: bound modifier `?` can only be applied to `Sized`
22-
--> $DIR/stranded_opaque.rs:11:18
30+
--> $DIR/stranded_opaque.rs:12:18
2331
|
2432
LL | fn foo() -> impl ?Future<Output = impl Send> {
2533
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
2634
|
2735
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
2836

2937
error[E0220]: associated type `Assoc` not found for `Trait`
30-
--> $DIR/stranded_opaque.rs:21:28
38+
--> $DIR/stranded_opaque.rs:22:28
3139
|
3240
LL | fn produce() -> impl Trait<Assoc = impl Trait> {
3341
| ^^^^^ associated type `Assoc` not found
3442
|
3543
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
3644

37-
error: aborting due to 5 previous errors
45+
error: unconstrained opaque type
46+
--> $DIR/stranded_opaque.rs:36:12
47+
|
48+
LL | type Foo = impl ?Future<Output = impl Send>;
49+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
50+
|
51+
= note: `Foo` must be used in combination with a concrete type within the same crate
52+
53+
error: bound modifier `?` can only be applied to `Sized`
54+
--> $DIR/stranded_opaque.rs:36:17
55+
|
56+
LL | type Foo = impl ?Future<Output = impl Send>;
57+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
58+
59+
error: bound modifier `?` can only be applied to `Sized`
60+
--> $DIR/stranded_opaque.rs:36:17
61+
|
62+
LL | type Foo = impl ?Future<Output = impl Send>;
63+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
64+
|
65+
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
66+
67+
error: unconstrained opaque type
68+
--> $DIR/stranded_opaque.rs:36:34
69+
|
70+
LL | type Foo = impl ?Future<Output = impl Send>;
71+
| ^^^^^^^^^
72+
|
73+
= note: `Foo` must be used in combination with a concrete type within the same crate
74+
75+
error: unconstrained opaque type
76+
--> $DIR/stranded_opaque.rs:42:17
77+
|
78+
LL | type Produce = impl Trait<Assoc = impl Trait>;
79+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
80+
|
81+
= note: `Produce` must be used in combination with a concrete type within the same crate
82+
83+
error[E0220]: associated type `Assoc` not found for `Trait`
84+
--> $DIR/stranded_opaque.rs:42:28
85+
|
86+
LL | type Produce = impl Trait<Assoc = impl Trait>;
87+
| ^^^^^ associated type `Assoc` not found
88+
89+
error[E0220]: associated type `Assoc` not found for `Trait`
90+
--> $DIR/stranded_opaque.rs:42:28
91+
|
92+
LL | type Produce = impl Trait<Assoc = impl Trait>;
93+
| ^^^^^ associated type `Assoc` not found
94+
|
95+
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
96+
97+
error: unconstrained opaque type
98+
--> $DIR/stranded_opaque.rs:42:36
99+
|
100+
LL | type Produce = impl Trait<Assoc = impl Trait>;
101+
| ^^^^^^^^^^
102+
|
103+
= note: `Produce` must be used in combination with a concrete type within the same crate
104+
105+
error: unconstrained opaque type
106+
--> $DIR/stranded_opaque.rs:48:32
107+
|
108+
LL | type IllFormedString = String<impl Trait>;
109+
| ^^^^^^^^^^
110+
|
111+
= note: `IllFormedString` must be used in combination with a concrete type within the same crate
112+
113+
error: aborting due to 15 previous errors
38114

39115
Some errors have detailed explanations: E0107, E0220.
40116
For more information about an error, try `rustc --explain E0107`.

0 commit comments

Comments
 (0)