Skip to content

Commit ff4db29

Browse files
Rollup merge of rust-lang#157131 - pbkx:issue-144888-ui-test, r=petrochenkov
Add regression test for issue rust-lang#144888 Issue rust-lang#144888 is labeled E-needs-test for an ICE involving `unhandled node Crate(Mod)`. This adds a focused UI regression test for the reduced example. The test is compile-fail, checks the current non-ICE diagnostics, and avoids the unrelated missing-main diagnostic by compiling as a library. Fixes rust-lang#144888.
2 parents 99bb120 + 8845779 commit ff4db29

2 files changed

Lines changed: 223 additions & 0 deletions

File tree

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
// Regression test for <https://github.com/rust-lang/rust/issues/144888>.
2+
// This used to ICE with `unhandled node Crate(Mod)`.
3+
4+
trait Super {
5+
type Assoc;
6+
}
7+
8+
impl dyn Foo<()> {}
9+
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
13+
where
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
19+
{
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
25+
}
26+
27+
trait Mirror {
28+
type Assoc;
29+
}
30+
31+
impl<T: Super<Assoc = ()>> Mirror for T {}
32+
//~^ ERROR not all trait items implemented
33+
34+
fn main() {}
Lines changed: 189 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,189 @@
1+
error[E0271]: type mismatch resolving `<Self as Super>::Assoc == ()`
2+
--> $DIR/unhandled-crate-mod-issue-144888.rs:20:5
3+
|
4+
LL | fn transmute(&self) {}
5+
| ^^^^^^^^^^^^^^^^^^^ expected `()`, found type parameter `T`
6+
|
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
11+
|
12+
LL | impl<T: Super<Assoc = ()>> Mirror for T {}
13+
| ---------- ^^^^^^ ^
14+
| |
15+
| unsatisfied trait bound introduced here
16+
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
22+
|
23+
note: required for `Self` to implement `Mirror`
24+
--> $DIR/unhandled-crate-mod-issue-144888.rs:31:28
25+
|
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
33+
|
34+
LL | trait Foo<T>: Super<Assoc = T>
35+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `()`, found type parameter `T`
36+
|
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
46+
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
52+
|
53+
note: required for `Self` to implement `Mirror`
54+
--> $DIR/unhandled-crate-mod-issue-144888.rs:31:28
55+
|
56+
LL | impl<T: Super<Assoc = ()>> Mirror for T {}
57+
| - ^^^^^^ ^
58+
| |
59+
| unsatisfied trait bound implicitly introduced here
60+
help: consider further restricting `Self`
61+
|
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
70+
...
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+
| +++++++
101+
102+
error[E0046]: not all trait items implemented, missing: `Assoc`
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
113+
|
114+
LL | trait Foo<T>: Super<Assoc = T>
115+
| - found this type parameter
116+
...
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+
| +++++++++++++++++
185+
186+
error: aborting due to 11 previous errors
187+
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)