Skip to content

Commit 58f40da

Browse files
committed
Add test
1 parent 34a8c73 commit 58f40da

File tree

2 files changed

+73
-0
lines changed

2 files changed

+73
-0
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
//@ compile-flags: -Znext-solver
2+
3+
// Test for https://github.com/rust-lang/trait-system-refactor-initiative/issues/235
4+
5+
// These are cases where an opaque types become "stranded" due to
6+
// some errors. Make sure we don't ICE in either case.
7+
8+
// Case 1: `impl Send` is stranded
9+
use std::future::Future;
10+
11+
fn foo() -> impl ?Future<Output = impl Send> {
12+
//~^ ERROR bound modifier `?` can only be applied to `Sized`
13+
//~| ERROR bound modifier `?` can only be applied to `Sized`
14+
()
15+
}
16+
17+
// Case 2: `Assoc = impl Trait` is stranded
18+
trait Trait {}
19+
impl Trait for i32 {}
20+
21+
fn produce() -> impl Trait<Assoc = impl Trait> {
22+
//~^ ERROR associated type `Assoc` not found for `Trait`
23+
//~| ERROR associated type `Assoc` not found for `Trait`
24+
16
25+
}
26+
27+
// Case 3: `impl Trait` is stranded
28+
fn ill_formed_string() -> String<impl Trait> {
29+
//~^ ERROR struct takes 0 generic arguments but 1 generic argument was supplied
30+
String::from("a string")
31+
}
32+
33+
fn main() {}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
error: bound modifier `?` can only be applied to `Sized`
2+
--> $DIR/stranded_opaque.rs:11:18
3+
|
4+
LL | fn foo() -> impl ?Future<Output = impl Send> {
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
6+
7+
error[E0220]: associated type `Assoc` not found for `Trait`
8+
--> $DIR/stranded_opaque.rs:21:28
9+
|
10+
LL | fn produce() -> impl Trait<Assoc = impl Trait> {
11+
| ^^^^^ associated type `Assoc` not found
12+
13+
error[E0107]: struct takes 0 generic arguments but 1 generic argument was supplied
14+
--> $DIR/stranded_opaque.rs:28:27
15+
|
16+
LL | fn ill_formed_string() -> String<impl Trait> {
17+
| ^^^^^^------------ help: remove the unnecessary generics
18+
| |
19+
| expected 0 generic arguments
20+
21+
error: bound modifier `?` can only be applied to `Sized`
22+
--> $DIR/stranded_opaque.rs:11:18
23+
|
24+
LL | fn foo() -> impl ?Future<Output = impl Send> {
25+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
26+
|
27+
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
28+
29+
error[E0220]: associated type `Assoc` not found for `Trait`
30+
--> $DIR/stranded_opaque.rs:21:28
31+
|
32+
LL | fn produce() -> impl Trait<Assoc = impl Trait> {
33+
| ^^^^^ associated type `Assoc` not found
34+
|
35+
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
36+
37+
error: aborting due to 5 previous errors
38+
39+
Some errors have detailed explanations: E0107, E0220.
40+
For more information about an error, try `rustc --explain E0107`.

0 commit comments

Comments
 (0)