Skip to content

Commit

Permalink
add test for ICE Where clause Binder(..) was applicable to `Obligat…
Browse files Browse the repository at this point in the history
…ion(..)` but now is not

Fixes #84727
  • Loading branch information
matthiaskrgr committed Mar 25, 2024
1 parent 5f95fc1 commit 6fe5555
Show file tree
Hide file tree
Showing 2 changed files with 85 additions and 0 deletions.
38 changes: 38 additions & 0 deletions tests/ui/traits/trait-selection-ice-84727.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// ICE Where clause `Binder(..)` was applicable to `Obligation(..)` but now is not
// issue: rust-lang/rust#84727

struct Cell<Fg, Bg = Fg> {
foreground: Color<Fg>,
//~^ ERROR cannot find type `Color` in this scope
background: Color<Bg>,
//~^ ERROR cannot find type `Color` in this scope
}

trait Over<Bottom, Output> {
fn over(self) -> Output;
}

impl<TopFg, TopBg, BottomFg, BottomBg, NewFg, NewBg>
Over<Cell<BottomFg, BottomBg>, Cell<NewFg, NewBg>> for Cell<TopFg, TopBg>
where
Self: Over<Color<BottomBg>, Cell<NewFg>>,
//~^ ERROR cannot find type `Color` in this scope
{
fn over(self) -> Cell<NewFg> {
//~^ ERROR mismatched types
self.over();
}
}

impl<'b, TopFg, TopBg, BottomFg, BottomBg> Over<&Cell<BottomFg, BottomBg>, ()>
for Cell<TopFg, TopBg>
where
Cell<TopFg, TopBg>: Over<Cell<BottomFg>, Cell<BottomFg>>,
{
fn over(self) -> Cell<NewBg> {
//~^ ERROR cannot find type `NewBg` in this scope
self.over();
}
}

pub fn main() {}
47 changes: 47 additions & 0 deletions tests/ui/traits/trait-selection-ice-84727.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
error[E0412]: cannot find type `Color` in this scope
--> $DIR/trait-selection-ice-84727.rs:5:17
|
LL | foreground: Color<Fg>,
| ^^^^^ not found in this scope

error[E0412]: cannot find type `Color` in this scope
--> $DIR/trait-selection-ice-84727.rs:7:17
|
LL | background: Color<Bg>,
| ^^^^^ not found in this scope

error[E0412]: cannot find type `Color` in this scope
--> $DIR/trait-selection-ice-84727.rs:18:16
|
LL | Self: Over<Color<BottomBg>, Cell<NewFg>>,
| ^^^^^ not found in this scope

error[E0412]: cannot find type `NewBg` in this scope
--> $DIR/trait-selection-ice-84727.rs:32:27
|
LL | fn over(self) -> Cell<NewBg> {
| ^^^^^ not found in this scope
|
help: you might be missing a type parameter
|
LL | impl<'b, TopFg, TopBg, BottomFg, BottomBg, NewBg> Over<&Cell<BottomFg, BottomBg>, ()>
| +++++++

error[E0308]: mismatched types
--> $DIR/trait-selection-ice-84727.rs:21:22
|
LL | fn over(self) -> Cell<NewFg> {
| ---- ^^^^^^^^^^^ expected `Cell<NewFg>`, found `()`
| |
| implicitly returns `()` as its body has no tail or `return` expression
LL |
LL | self.over();
| - help: remove this semicolon to return this value
|
= note: expected struct `Cell<NewFg>`
found unit type `()`

error: aborting due to 5 previous errors

Some errors have detailed explanations: E0308, E0412.
For more information about an error, try `rustc --explain E0308`.

0 comments on commit 6fe5555

Please sign in to comment.