Skip to content

Commit 8845779

Browse files
committed
Use minimized unhandled Crate(Mod) regression
1 parent 55cb982 commit 8845779

2 files changed

Lines changed: 189 additions & 58 deletions

File tree

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,34 @@
11
// Regression test for <https://github.com/rust-lang/rust/issues/144888>.
22
// This used to ICE with `unhandled node Crate(Mod)`.
33

4-
#![crate_type = "lib"]
5-
6-
struct ActuallySuper;
7-
8-
trait Super<Q> {
4+
trait Super {
95
type Assoc;
106
}
117

12-
trait Dyn {}
13-
impl<T, U> Dyn for dyn Foo<T, U> + '_ {}
14-
//~^ ERROR the trait `Foo` is not dyn compatible
8+
impl dyn Foo<()> {}
159

16-
trait Foo<T, U>: Super<ActuallySuper, Assoc = T>
10+
trait Foo<T>: Super<Assoc = T>
11+
//~^ ERROR type mismatch resolving
12+
//~| ERROR the size for values of type `Self` cannot be known at compilation time
1713
where
18-
<Self as Mirror>::Assoc: Super,
19-
//~^ ERROR missing generics for trait `Super`
14+
<Self as Mirror>::Assoc: Clone,
15+
//~^ ERROR type mismatch resolving
16+
//~| ERROR the size for values of type `Self` cannot be known at compilation time
17+
//~| ERROR type mismatch resolving
18+
//~| ERROR the size for values of type `Self` cannot be known at compilation time
2019
{
21-
fn transmute(&self, t: T) -> <Self as Super>::Assoc;
22-
//~^ ERROR missing generics for trait `Super`
20+
fn transmute(&self) {}
21+
//~^ ERROR type mismatch resolving
22+
//~| ERROR the size for values of type `Self` cannot be known at compilation time
23+
//~| ERROR type mismatch resolving
24+
//~| ERROR the size for values of type `Self` cannot be known at compilation time
2325
}
2426

2527
trait Mirror {
26-
type Assoc: ?Sized;
28+
type Assoc;
2729
}
2830

29-
impl<T: Super<ActuallySuper, Assoc = T>> Mirror for T {}
31+
impl<T: Super<Assoc = ()>> Mirror for T {}
3032
//~^ ERROR not all trait items implemented
33+
34+
fn main() {}
Lines changed: 170 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,189 @@
1-
error[E0107]: missing generics for trait `Super`
2-
--> $DIR/unhandled-crate-mod-issue-144888.rs:18:30
1+
error[E0271]: type mismatch resolving `<Self as Super>::Assoc == ()`
2+
--> $DIR/unhandled-crate-mod-issue-144888.rs:20:5
33
|
4-
LL | <Self as Mirror>::Assoc: Super,
5-
| ^^^^^ expected 1 generic argument
4+
LL | fn transmute(&self) {}
5+
| ^^^^^^^^^^^^^^^^^^^ expected `()`, found type parameter `T`
66
|
7-
note: trait defined here, with 1 generic parameter: `Q`
8-
--> $DIR/unhandled-crate-mod-issue-144888.rs:8:7
7+
= note: expected unit type `()`
8+
found type parameter `T`
9+
note: required for `Self` to implement `Mirror`
10+
--> $DIR/unhandled-crate-mod-issue-144888.rs:31:28
911
|
10-
LL | trait Super<Q> {
11-
| ^^^^^ -
12-
help: add missing generic argument
13-
|
14-
LL | <Self as Mirror>::Assoc: Super<Q>,
15-
| +++
12+
LL | impl<T: Super<Assoc = ()>> Mirror for T {}
13+
| ---------- ^^^^^^ ^
14+
| |
15+
| unsatisfied trait bound introduced here
1616

17-
error[E0107]: missing generics for trait `Super`
18-
--> $DIR/unhandled-crate-mod-issue-144888.rs:21:43
17+
error[E0277]: the size for values of type `Self` cannot be known at compilation time
18+
--> $DIR/unhandled-crate-mod-issue-144888.rs:20:5
19+
|
20+
LL | fn transmute(&self) {}
21+
| ^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
1922
|
20-
LL | fn transmute(&self, t: T) -> <Self as Super>::Assoc;
21-
| ^^^^^ expected 1 generic argument
23+
note: required for `Self` to implement `Mirror`
24+
--> $DIR/unhandled-crate-mod-issue-144888.rs:31:28
2225
|
23-
note: trait defined here, with 1 generic parameter: `Q`
24-
--> $DIR/unhandled-crate-mod-issue-144888.rs:8:7
26+
LL | impl<T: Super<Assoc = ()>> Mirror for T {}
27+
| - ^^^^^^ ^
28+
| |
29+
| unsatisfied trait bound implicitly introduced here
30+
31+
error[E0271]: type mismatch resolving `<Self as Super>::Assoc == ()`
32+
--> $DIR/unhandled-crate-mod-issue-144888.rs:10:1
2533
|
26-
LL | trait Super<Q> {
27-
| ^^^^^ -
28-
help: add missing generic argument
34+
LL | trait Foo<T>: Super<Assoc = T>
35+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `()`, found type parameter `T`
2936
|
30-
LL | fn transmute(&self, t: T) -> <Self as Super<Q>>::Assoc;
31-
| +++
37+
= note: expected unit type `()`
38+
found type parameter `T`
39+
note: required for `Self` to implement `Mirror`
40+
--> $DIR/unhandled-crate-mod-issue-144888.rs:31:28
41+
|
42+
LL | impl<T: Super<Assoc = ()>> Mirror for T {}
43+
| ---------- ^^^^^^ ^
44+
| |
45+
| unsatisfied trait bound introduced here
3246

33-
error[E0038]: the trait `Foo` is not dyn compatible
34-
--> $DIR/unhandled-crate-mod-issue-144888.rs:13:20
47+
error[E0277]: the size for values of type `Self` cannot be known at compilation time
48+
--> $DIR/unhandled-crate-mod-issue-144888.rs:10:1
49+
|
50+
LL | trait Foo<T>: Super<Assoc = T>
51+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
3552
|
36-
LL | impl<T, U> Dyn for dyn Foo<T, U> + '_ {}
37-
| ^^^^^^^^^^^^^^^^^^ `Foo` is not dyn compatible
53+
note: required for `Self` to implement `Mirror`
54+
--> $DIR/unhandled-crate-mod-issue-144888.rs:31:28
3855
|
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
56+
LL | impl<T: Super<Assoc = ()>> Mirror for T {}
57+
| - ^^^^^^ ^
58+
| |
59+
| unsatisfied trait bound implicitly introduced here
60+
help: consider further restricting `Self`
4261
|
43-
LL | trait Foo<T, U>: Super<ActuallySuper, Assoc = T>
44-
| --- this trait is not dyn compatible...
62+
LL | trait Foo<T>: Super<Assoc = T> + Sized
63+
| +++++++
64+
65+
error[E0271]: type mismatch resolving `<Self as Super>::Assoc == ()`
66+
--> $DIR/unhandled-crate-mod-issue-144888.rs:14:30
67+
|
68+
LL | trait Foo<T>: Super<Assoc = T>
69+
| - found this type parameter
4570
...
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
71+
LL | <Self as Mirror>::Assoc: Clone,
72+
| ^^^^^ expected `()`, found type parameter `T`
73+
|
74+
= note: expected unit type `()`
75+
found type parameter `T`
76+
note: required for `Self` to implement `Mirror`
77+
--> $DIR/unhandled-crate-mod-issue-144888.rs:31:28
78+
|
79+
LL | impl<T: Super<Assoc = ()>> Mirror for T {}
80+
| ---------- ^^^^^^ ^
81+
| |
82+
| unsatisfied trait bound introduced here
83+
84+
error[E0277]: the size for values of type `Self` cannot be known at compilation time
85+
--> $DIR/unhandled-crate-mod-issue-144888.rs:14:30
86+
|
87+
LL | <Self as Mirror>::Assoc: Clone,
88+
| ^^^^^ doesn't have a size known at compile-time
89+
|
90+
note: required for `Self` to implement `Mirror`
91+
--> $DIR/unhandled-crate-mod-issue-144888.rs:31:28
92+
|
93+
LL | impl<T: Super<Assoc = ()>> Mirror for T {}
94+
| - ^^^^^^ ^
95+
| |
96+
| unsatisfied trait bound implicitly introduced here
97+
help: consider further restricting `Self`
98+
|
99+
LL | trait Foo<T>: Super<Assoc = T> + Sized
100+
| +++++++
49101

50102
error[E0046]: not all trait items implemented, missing: `Assoc`
51-
--> $DIR/unhandled-crate-mod-issue-144888.rs:29:1
103+
--> $DIR/unhandled-crate-mod-issue-144888.rs:31:1
104+
|
105+
LL | type Assoc;
106+
| ---------- `Assoc` from trait
107+
...
108+
LL | impl<T: Super<Assoc = ()>> Mirror for T {}
109+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `Assoc` in implementation
110+
111+
error[E0271]: type mismatch resolving `<Self as Super>::Assoc == ()`
112+
--> $DIR/unhandled-crate-mod-issue-144888.rs:20:5
52113
|
53-
LL | type Assoc: ?Sized;
54-
| ------------------ `Assoc` from trait
114+
LL | trait Foo<T>: Super<Assoc = T>
115+
| - found this type parameter
55116
...
56-
LL | impl<T: Super<ActuallySuper, Assoc = T>> Mirror for T {}
57-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `Assoc` in implementation
117+
LL | fn transmute(&self) {}
118+
| ^^^^^^^^^^^^^^^^^^^ expected `()`, found type parameter `T`
119+
|
120+
= note: expected unit type `()`
121+
found type parameter `T`
122+
note: required for `Self` to implement `Mirror`
123+
--> $DIR/unhandled-crate-mod-issue-144888.rs:31:28
124+
|
125+
LL | impl<T: Super<Assoc = ()>> Mirror for T {}
126+
| ---------- ^^^^^^ ^
127+
| |
128+
| unsatisfied trait bound introduced here
129+
130+
error[E0277]: the size for values of type `Self` cannot be known at compilation time
131+
--> $DIR/unhandled-crate-mod-issue-144888.rs:20:5
132+
|
133+
LL | fn transmute(&self) {}
134+
| ^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
135+
|
136+
note: required for `Self` to implement `Mirror`
137+
--> $DIR/unhandled-crate-mod-issue-144888.rs:31:28
138+
|
139+
LL | impl<T: Super<Assoc = ()>> Mirror for T {}
140+
| - ^^^^^^ ^
141+
| |
142+
| unsatisfied trait bound implicitly introduced here
143+
help: consider further restricting `Self`
144+
|
145+
LL | fn transmute(&self) where Self: Sized {}
146+
| +++++++++++++++++
147+
148+
error[E0271]: type mismatch resolving `<Self as Super>::Assoc == ()`
149+
--> $DIR/unhandled-crate-mod-issue-144888.rs:14:30
150+
|
151+
LL | trait Foo<T>: Super<Assoc = T>
152+
| - found this type parameter
153+
...
154+
LL | <Self as Mirror>::Assoc: Clone,
155+
| ^^^^^ expected `()`, found type parameter `T`
156+
|
157+
= note: expected unit type `()`
158+
found type parameter `T`
159+
note: required for `Self` to implement `Mirror`
160+
--> $DIR/unhandled-crate-mod-issue-144888.rs:31:28
161+
|
162+
LL | impl<T: Super<Assoc = ()>> Mirror for T {}
163+
| ---------- ^^^^^^ ^
164+
| |
165+
| unsatisfied trait bound introduced here
166+
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
167+
168+
error[E0277]: the size for values of type `Self` cannot be known at compilation time
169+
--> $DIR/unhandled-crate-mod-issue-144888.rs:14:30
170+
|
171+
LL | <Self as Mirror>::Assoc: Clone,
172+
| ^^^^^ doesn't have a size known at compile-time
173+
|
174+
note: required for `Self` to implement `Mirror`
175+
--> $DIR/unhandled-crate-mod-issue-144888.rs:31:28
176+
|
177+
LL | impl<T: Super<Assoc = ()>> Mirror for T {}
178+
| - ^^^^^^ ^
179+
| |
180+
| unsatisfied trait bound implicitly introduced here
181+
help: consider further restricting `Self`
182+
|
183+
LL | fn transmute(&self) where Self: Sized {}
184+
| +++++++++++++++++
58185

59-
error: aborting due to 4 previous errors
186+
error: aborting due to 11 previous errors
60187

61-
Some errors have detailed explanations: E0038, E0046, E0107.
62-
For more information about an error, try `rustc --explain E0038`.
188+
Some errors have detailed explanations: E0046, E0271, E0277.
189+
For more information about an error, try `rustc --explain E0046`.

0 commit comments

Comments
 (0)