Skip to content

Commit 55cb982

Browse files
committed
Add regression test for unhandled Crate(Mod) ICE
1 parent 6368fd5 commit 55cb982

2 files changed

Lines changed: 92 additions & 0 deletions

File tree

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// Regression test for <https://github.com/rust-lang/rust/issues/144888>.
2+
// This used to ICE with `unhandled node Crate(Mod)`.
3+
4+
#![crate_type = "lib"]
5+
6+
struct ActuallySuper;
7+
8+
trait Super<Q> {
9+
type Assoc;
10+
}
11+
12+
trait Dyn {}
13+
impl<T, U> Dyn for dyn Foo<T, U> + '_ {}
14+
//~^ ERROR the trait `Foo` is not dyn compatible
15+
16+
trait Foo<T, U>: Super<ActuallySuper, Assoc = T>
17+
where
18+
<Self as Mirror>::Assoc: Super,
19+
//~^ ERROR missing generics for trait `Super`
20+
{
21+
fn transmute(&self, t: T) -> <Self as Super>::Assoc;
22+
//~^ ERROR missing generics for trait `Super`
23+
}
24+
25+
trait Mirror {
26+
type Assoc: ?Sized;
27+
}
28+
29+
impl<T: Super<ActuallySuper, Assoc = T>> Mirror for T {}
30+
//~^ ERROR not all trait items implemented
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
error[E0107]: missing generics for trait `Super`
2+
--> $DIR/unhandled-crate-mod-issue-144888.rs:18:30
3+
|
4+
LL | <Self as Mirror>::Assoc: Super,
5+
| ^^^^^ expected 1 generic argument
6+
|
7+
note: trait defined here, with 1 generic parameter: `Q`
8+
--> $DIR/unhandled-crate-mod-issue-144888.rs:8:7
9+
|
10+
LL | trait Super<Q> {
11+
| ^^^^^ -
12+
help: add missing generic argument
13+
|
14+
LL | <Self as Mirror>::Assoc: Super<Q>,
15+
| +++
16+
17+
error[E0107]: missing generics for trait `Super`
18+
--> $DIR/unhandled-crate-mod-issue-144888.rs:21:43
19+
|
20+
LL | fn transmute(&self, t: T) -> <Self as Super>::Assoc;
21+
| ^^^^^ expected 1 generic argument
22+
|
23+
note: trait defined here, with 1 generic parameter: `Q`
24+
--> $DIR/unhandled-crate-mod-issue-144888.rs:8:7
25+
|
26+
LL | trait Super<Q> {
27+
| ^^^^^ -
28+
help: add missing generic argument
29+
|
30+
LL | fn transmute(&self, t: T) -> <Self as Super<Q>>::Assoc;
31+
| +++
32+
33+
error[E0038]: the trait `Foo` is not dyn compatible
34+
--> $DIR/unhandled-crate-mod-issue-144888.rs:13:20
35+
|
36+
LL | impl<T, U> Dyn for dyn Foo<T, U> + '_ {}
37+
| ^^^^^^^^^^^^^^^^^^ `Foo` is not dyn compatible
38+
|
39+
note: for a trait to be dyn compatible it needs to allow building a vtable
40+
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#dyn-compatibility>
41+
--> $DIR/unhandled-crate-mod-issue-144888.rs:21:34
42+
|
43+
LL | trait Foo<T, U>: Super<ActuallySuper, Assoc = T>
44+
| --- this trait is not dyn compatible...
45+
...
46+
LL | fn transmute(&self, t: T) -> <Self as Super>::Assoc;
47+
| ^^^^^^^^^^^^^^^^^^^^^^ ...because method `transmute` references the `Self` type in its return type
48+
= help: consider moving `transmute` to another trait
49+
50+
error[E0046]: not all trait items implemented, missing: `Assoc`
51+
--> $DIR/unhandled-crate-mod-issue-144888.rs:29:1
52+
|
53+
LL | type Assoc: ?Sized;
54+
| ------------------ `Assoc` from trait
55+
...
56+
LL | impl<T: Super<ActuallySuper, Assoc = T>> Mirror for T {}
57+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `Assoc` in implementation
58+
59+
error: aborting due to 4 previous errors
60+
61+
Some errors have detailed explanations: E0038, E0046, E0107.
62+
For more information about an error, try `rustc --explain E0038`.

0 commit comments

Comments
 (0)