Skip to content

Commit 8d99194

Browse files
author
Lukas Markeffsky
committed
add test for assoc type mismatch in supertrait
1 parent 6cbf092 commit 8d99194

File tree

2 files changed

+229
-0
lines changed

2 files changed

+229
-0
lines changed
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
trait Super {
2+
type Assoc;
3+
}
4+
impl Super for () {
5+
type Assoc = u8;
6+
}
7+
trait Sub: Super<Assoc = u16> {}
8+
9+
trait BoundOnSelf: Sub {}
10+
impl BoundOnSelf for () {}
11+
//~^ ERROR the trait bound `(): Sub` is not satisfied
12+
//~| ERROR type mismatch resolving `<() as Super>::Assoc == u16`
13+
14+
trait BoundOnParam<T: Sub> {}
15+
impl BoundOnParam<()> for () {}
16+
//~^ ERROR the trait bound `(): Sub` is not satisfied
17+
//~| ERROR type mismatch resolving `<() as Super>::Assoc == u16`
18+
19+
trait BoundOnAssoc {
20+
type Assoc: Sub;
21+
}
22+
impl BoundOnAssoc for () {
23+
type Assoc = ();
24+
//~^ ERROR the trait bound `(): Sub` is not satisfied
25+
//~| ERROR type mismatch resolving `<() as Super>::Assoc == u16`
26+
}
27+
28+
trait BoundOnGat where Self::Assoc<u8>: Sub {
29+
type Assoc<T>;
30+
}
31+
impl BoundOnGat for u8 {
32+
//~^ ERROR type mismatch resolving `<() as Super>::Assoc == u16`
33+
type Assoc<T> = ();
34+
//~^ ERROR the trait bound `(): Sub` is not satisfied
35+
}
36+
37+
fn trivial_bound() where (): Sub {}
38+
//~^ ERROR the trait bound `(): Sub` is not satisfied
39+
//~| ERROR type mismatch resolving `<() as Super>::Assoc == u16`
40+
41+
fn main() {}
Lines changed: 188 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,188 @@
1+
error[E0277]: the trait bound `(): Sub` is not satisfied
2+
--> $DIR/super-assoc-mismatch.rs:10:22
3+
|
4+
LL | impl BoundOnSelf for () {}
5+
| ^^ the trait `Sub` is not implemented for `()`
6+
|
7+
help: this trait has no implementations, consider adding one
8+
--> $DIR/super-assoc-mismatch.rs:7:1
9+
|
10+
LL | trait Sub: Super<Assoc = u16> {}
11+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
12+
note: required by a bound in `BoundOnSelf`
13+
--> $DIR/super-assoc-mismatch.rs:9:20
14+
|
15+
LL | trait BoundOnSelf: Sub {}
16+
| ^^^ required by this bound in `BoundOnSelf`
17+
18+
error[E0271]: type mismatch resolving `<() as Super>::Assoc == u16`
19+
--> $DIR/super-assoc-mismatch.rs:10:6
20+
|
21+
LL | impl BoundOnSelf for () {}
22+
| ^^^^^^^^^^^ type mismatch resolving `<() as Super>::Assoc == u16`
23+
|
24+
note: expected this to be `u16`
25+
--> $DIR/super-assoc-mismatch.rs:5:18
26+
|
27+
LL | type Assoc = u8;
28+
| ^^
29+
note: required for `()` to implement `Sub`
30+
--> $DIR/super-assoc-mismatch.rs:7:7
31+
|
32+
LL | trait Sub: Super<Assoc = u16> {}
33+
| ^^^
34+
note: required by a bound in `BoundOnSelf`
35+
--> $DIR/super-assoc-mismatch.rs:9:20
36+
|
37+
LL | trait BoundOnSelf: Sub {}
38+
| ^^^ required by this bound in `BoundOnSelf`
39+
40+
error[E0277]: the trait bound `(): Sub` is not satisfied
41+
--> $DIR/super-assoc-mismatch.rs:15:27
42+
|
43+
LL | impl BoundOnParam<()> for () {}
44+
| ^^ the trait `Sub` is not implemented for `()`
45+
|
46+
help: this trait has no implementations, consider adding one
47+
--> $DIR/super-assoc-mismatch.rs:7:1
48+
|
49+
LL | trait Sub: Super<Assoc = u16> {}
50+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
51+
note: required by a bound in `BoundOnParam`
52+
--> $DIR/super-assoc-mismatch.rs:14:23
53+
|
54+
LL | trait BoundOnParam<T: Sub> {}
55+
| ^^^ required by this bound in `BoundOnParam`
56+
57+
error[E0271]: type mismatch resolving `<() as Super>::Assoc == u16`
58+
--> $DIR/super-assoc-mismatch.rs:15:6
59+
|
60+
LL | impl BoundOnParam<()> for () {}
61+
| ^^^^^^^^^^^^^^^^ type mismatch resolving `<() as Super>::Assoc == u16`
62+
|
63+
note: expected this to be `u16`
64+
--> $DIR/super-assoc-mismatch.rs:5:18
65+
|
66+
LL | type Assoc = u8;
67+
| ^^
68+
note: required for `()` to implement `Sub`
69+
--> $DIR/super-assoc-mismatch.rs:7:7
70+
|
71+
LL | trait Sub: Super<Assoc = u16> {}
72+
| ^^^
73+
note: required by a bound in `BoundOnParam`
74+
--> $DIR/super-assoc-mismatch.rs:14:23
75+
|
76+
LL | trait BoundOnParam<T: Sub> {}
77+
| ^^^ required by this bound in `BoundOnParam`
78+
79+
error[E0277]: the trait bound `(): Sub` is not satisfied
80+
--> $DIR/super-assoc-mismatch.rs:23:18
81+
|
82+
LL | type Assoc = ();
83+
| ^^ the trait `Sub` is not implemented for `()`
84+
|
85+
help: this trait has no implementations, consider adding one
86+
--> $DIR/super-assoc-mismatch.rs:7:1
87+
|
88+
LL | trait Sub: Super<Assoc = u16> {}
89+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
90+
note: required by a bound in `BoundOnAssoc::Assoc`
91+
--> $DIR/super-assoc-mismatch.rs:20:17
92+
|
93+
LL | type Assoc: Sub;
94+
| ^^^ required by this bound in `BoundOnAssoc::Assoc`
95+
96+
error[E0271]: type mismatch resolving `<() as Super>::Assoc == u16`
97+
--> $DIR/super-assoc-mismatch.rs:23:18
98+
|
99+
LL | type Assoc = ();
100+
| ^^ type mismatch resolving `<() as Super>::Assoc == u16`
101+
|
102+
note: expected this to be `u16`
103+
--> $DIR/super-assoc-mismatch.rs:5:18
104+
|
105+
LL | type Assoc = u8;
106+
| ^^
107+
note: required for `<() as BoundOnAssoc>::Assoc` to implement `Sub`
108+
--> $DIR/super-assoc-mismatch.rs:7:7
109+
|
110+
LL | trait Sub: Super<Assoc = u16> {}
111+
| ^^^
112+
note: required by a bound in `BoundOnAssoc::Assoc`
113+
--> $DIR/super-assoc-mismatch.rs:20:17
114+
|
115+
LL | type Assoc: Sub;
116+
| ^^^ required by this bound in `BoundOnAssoc::Assoc`
117+
118+
error[E0277]: the trait bound `(): Sub` is not satisfied
119+
--> $DIR/super-assoc-mismatch.rs:33:21
120+
|
121+
LL | type Assoc<T> = ();
122+
| ^^ the trait `Sub` is not implemented for `()`, which is required by `<u8 as BoundOnGat>::Assoc<u8>: Sub`
123+
|
124+
help: this trait has no implementations, consider adding one
125+
--> $DIR/super-assoc-mismatch.rs:7:1
126+
|
127+
LL | trait Sub: Super<Assoc = u16> {}
128+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
129+
note: required by a bound in `BoundOnGat`
130+
--> $DIR/super-assoc-mismatch.rs:28:41
131+
|
132+
LL | trait BoundOnGat where Self::Assoc<u8>: Sub {
133+
| ^^^ required by this bound in `BoundOnGat`
134+
135+
error[E0271]: type mismatch resolving `<() as Super>::Assoc == u16`
136+
--> $DIR/super-assoc-mismatch.rs:31:6
137+
|
138+
LL | impl BoundOnGat for u8 {
139+
| ^^^^^^^^^^ type mismatch resolving `<() as Super>::Assoc == u16`
140+
|
141+
note: expected this to be `u16`
142+
--> $DIR/super-assoc-mismatch.rs:5:18
143+
|
144+
LL | type Assoc = u8;
145+
| ^^
146+
note: required for `<u8 as BoundOnGat>::Assoc<u8>` to implement `Sub`
147+
--> $DIR/super-assoc-mismatch.rs:7:7
148+
|
149+
LL | trait Sub: Super<Assoc = u16> {}
150+
| ^^^
151+
note: required by a bound in `BoundOnGat`
152+
--> $DIR/super-assoc-mismatch.rs:28:41
153+
|
154+
LL | trait BoundOnGat where Self::Assoc<u8>: Sub {
155+
| ^^^ required by this bound in `BoundOnGat`
156+
157+
error[E0277]: the trait bound `(): Sub` is not satisfied
158+
--> $DIR/super-assoc-mismatch.rs:37:26
159+
|
160+
LL | fn trivial_bound() where (): Sub {}
161+
| ^^^^^^^ the trait `Sub` is not implemented for `()`
162+
|
163+
help: this trait has no implementations, consider adding one
164+
--> $DIR/super-assoc-mismatch.rs:7:1
165+
|
166+
LL | trait Sub: Super<Assoc = u16> {}
167+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
168+
= help: see issue #48214
169+
= help: add `#![feature(trivial_bounds)]` to the crate attributes to enable
170+
171+
error[E0271]: type mismatch resolving `<() as Super>::Assoc == u16`
172+
--> $DIR/super-assoc-mismatch.rs:37:26
173+
|
174+
LL | fn trivial_bound() where (): Sub {}
175+
| ^^^^^^^ type mismatch resolving `<() as Super>::Assoc == u16`
176+
|
177+
note: expected this to be `u8`
178+
--> $DIR/super-assoc-mismatch.rs:5:18
179+
|
180+
LL | type Assoc = u8;
181+
| ^^
182+
= help: see issue #48214
183+
= help: add `#![feature(trivial_bounds)]` to the crate attributes to enable
184+
185+
error: aborting due to 10 previous errors
186+
187+
Some errors have detailed explanations: E0271, E0277.
188+
For more information about an error, try `rustc --explain E0271`.

0 commit comments

Comments
 (0)