From 6fe555549bed31133f6035e55b44cf918567046c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Kr=C3=BCger?= Date: Mon, 25 Mar 2024 20:20:01 +0100 Subject: [PATCH] add test for ICE Where clause `Binder(..)` was applicable to `Obligation(..)` but now is not Fixes https://github.com/rust-lang/rust/issues/84727 --- tests/ui/traits/trait-selection-ice-84727.rs | 38 +++++++++++++++ .../traits/trait-selection-ice-84727.stderr | 47 +++++++++++++++++++ 2 files changed, 85 insertions(+) create mode 100644 tests/ui/traits/trait-selection-ice-84727.rs create mode 100644 tests/ui/traits/trait-selection-ice-84727.stderr diff --git a/tests/ui/traits/trait-selection-ice-84727.rs b/tests/ui/traits/trait-selection-ice-84727.rs new file mode 100644 index 0000000000000..08a282892a59c --- /dev/null +++ b/tests/ui/traits/trait-selection-ice-84727.rs @@ -0,0 +1,38 @@ +// ICE Where clause `Binder(..)` was applicable to `Obligation(..)` but now is not +// issue: rust-lang/rust#84727 + +struct Cell { + foreground: Color, + //~^ ERROR cannot find type `Color` in this scope + background: Color, + //~^ ERROR cannot find type `Color` in this scope +} + +trait Over { + fn over(self) -> Output; +} + +impl + Over, Cell> for Cell +where + Self: Over, Cell>, + //~^ ERROR cannot find type `Color` in this scope +{ + fn over(self) -> Cell { + //~^ ERROR mismatched types + self.over(); + } +} + +impl<'b, TopFg, TopBg, BottomFg, BottomBg> Over<&Cell, ()> + for Cell +where + Cell: Over, Cell>, +{ + fn over(self) -> Cell { + //~^ ERROR cannot find type `NewBg` in this scope + self.over(); + } +} + +pub fn main() {} diff --git a/tests/ui/traits/trait-selection-ice-84727.stderr b/tests/ui/traits/trait-selection-ice-84727.stderr new file mode 100644 index 0000000000000..d4bc4163897c4 --- /dev/null +++ b/tests/ui/traits/trait-selection-ice-84727.stderr @@ -0,0 +1,47 @@ +error[E0412]: cannot find type `Color` in this scope + --> $DIR/trait-selection-ice-84727.rs:5:17 + | +LL | foreground: Color, + | ^^^^^ 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, + | ^^^^^ 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, Cell>, + | ^^^^^ 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 { + | ^^^^^ not found in this scope + | +help: you might be missing a type parameter + | +LL | impl<'b, TopFg, TopBg, BottomFg, BottomBg, NewBg> Over<&Cell, ()> + | +++++++ + +error[E0308]: mismatched types + --> $DIR/trait-selection-ice-84727.rs:21:22 + | +LL | fn over(self) -> Cell { + | ---- ^^^^^^^^^^^ expected `Cell`, 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` + 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`.