Skip to content

Commit 6fe5555

Browse files
committed
add test for ICE Where clause Binder(..) was applicable to Obligation(..) but now is not
Fixes rust-lang#84727
1 parent 5f95fc1 commit 6fe5555

File tree

2 files changed

+85
-0
lines changed

2 files changed

+85
-0
lines changed

Diff for: tests/ui/traits/trait-selection-ice-84727.rs

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
// ICE Where clause `Binder(..)` was applicable to `Obligation(..)` but now is not
2+
// issue: rust-lang/rust#84727
3+
4+
struct Cell<Fg, Bg = Fg> {
5+
foreground: Color<Fg>,
6+
//~^ ERROR cannot find type `Color` in this scope
7+
background: Color<Bg>,
8+
//~^ ERROR cannot find type `Color` in this scope
9+
}
10+
11+
trait Over<Bottom, Output> {
12+
fn over(self) -> Output;
13+
}
14+
15+
impl<TopFg, TopBg, BottomFg, BottomBg, NewFg, NewBg>
16+
Over<Cell<BottomFg, BottomBg>, Cell<NewFg, NewBg>> for Cell<TopFg, TopBg>
17+
where
18+
Self: Over<Color<BottomBg>, Cell<NewFg>>,
19+
//~^ ERROR cannot find type `Color` in this scope
20+
{
21+
fn over(self) -> Cell<NewFg> {
22+
//~^ ERROR mismatched types
23+
self.over();
24+
}
25+
}
26+
27+
impl<'b, TopFg, TopBg, BottomFg, BottomBg> Over<&Cell<BottomFg, BottomBg>, ()>
28+
for Cell<TopFg, TopBg>
29+
where
30+
Cell<TopFg, TopBg>: Over<Cell<BottomFg>, Cell<BottomFg>>,
31+
{
32+
fn over(self) -> Cell<NewBg> {
33+
//~^ ERROR cannot find type `NewBg` in this scope
34+
self.over();
35+
}
36+
}
37+
38+
pub fn main() {}

Diff for: tests/ui/traits/trait-selection-ice-84727.stderr

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
error[E0412]: cannot find type `Color` in this scope
2+
--> $DIR/trait-selection-ice-84727.rs:5:17
3+
|
4+
LL | foreground: Color<Fg>,
5+
| ^^^^^ not found in this scope
6+
7+
error[E0412]: cannot find type `Color` in this scope
8+
--> $DIR/trait-selection-ice-84727.rs:7:17
9+
|
10+
LL | background: Color<Bg>,
11+
| ^^^^^ not found in this scope
12+
13+
error[E0412]: cannot find type `Color` in this scope
14+
--> $DIR/trait-selection-ice-84727.rs:18:16
15+
|
16+
LL | Self: Over<Color<BottomBg>, Cell<NewFg>>,
17+
| ^^^^^ not found in this scope
18+
19+
error[E0412]: cannot find type `NewBg` in this scope
20+
--> $DIR/trait-selection-ice-84727.rs:32:27
21+
|
22+
LL | fn over(self) -> Cell<NewBg> {
23+
| ^^^^^ not found in this scope
24+
|
25+
help: you might be missing a type parameter
26+
|
27+
LL | impl<'b, TopFg, TopBg, BottomFg, BottomBg, NewBg> Over<&Cell<BottomFg, BottomBg>, ()>
28+
| +++++++
29+
30+
error[E0308]: mismatched types
31+
--> $DIR/trait-selection-ice-84727.rs:21:22
32+
|
33+
LL | fn over(self) -> Cell<NewFg> {
34+
| ---- ^^^^^^^^^^^ expected `Cell<NewFg>`, found `()`
35+
| |
36+
| implicitly returns `()` as its body has no tail or `return` expression
37+
LL |
38+
LL | self.over();
39+
| - help: remove this semicolon to return this value
40+
|
41+
= note: expected struct `Cell<NewFg>`
42+
found unit type `()`
43+
44+
error: aborting due to 5 previous errors
45+
46+
Some errors have detailed explanations: E0308, E0412.
47+
For more information about an error, try `rustc --explain E0308`.

0 commit comments

Comments
 (0)