diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2024-05-06 18:50:35 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-05-06 18:50:35 +0200 |
| commit | 43de8225dc2bdf2ad9a58f42192a32bf2b2eae98 (patch) | |
| tree | b474324b8c1b76a6ed480ba7f6460263e0e2cc95 /tests | |
| parent | 2d557ba9f4cbc1cdc01a515864867c12e3b85ad1 (diff) | |
| parent | 4e3350d43b2546281784d2ce4cf6803473a81645 (diff) | |
| download | rust-43de8225dc2bdf2ad9a58f42192a32bf2b2eae98.tar.gz rust-43de8225dc2bdf2ad9a58f42192a32bf2b2eae98.zip | |
Rollup merge of #124771 - compiler-errors:cand-has-failing-wc, r=lcnr
Don't consider candidates with no failing where clauses when refining obligation causes in new solver Improves error messages when we have param-env candidates that don't deeply unify (i.e. after alias-bounds). r? lcnr
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/ui/traits/next-solver/diagnostics/where-clause-doesnt-apply.rs | 22 | ||||
| -rw-r--r-- | tests/ui/traits/next-solver/diagnostics/where-clause-doesnt-apply.stderr | 22 |
2 files changed, 44 insertions, 0 deletions
diff --git a/tests/ui/traits/next-solver/diagnostics/where-clause-doesnt-apply.rs b/tests/ui/traits/next-solver/diagnostics/where-clause-doesnt-apply.rs new file mode 100644 index 00000000000..4737546e404 --- /dev/null +++ b/tests/ui/traits/next-solver/diagnostics/where-clause-doesnt-apply.rs @@ -0,0 +1,22 @@ +trait Foo {} +trait Bar {} + +impl<T> Foo for T where T: Bar {} +fn needs_foo(_: impl Foo) {} + +trait Mirror { + type Mirror; +} +impl<T> Mirror for T { + type Mirror = T; +} + +// Make sure the `Alias: Foo` bound doesn't "shadow" the impl, since the +// impl is really the only candidate we care about here for the purpose +// of error reporting. +fn hello<T>() where <T as Mirror>::Mirror: Foo { + needs_foo(()); + //~^ ERROR the trait bound `(): Foo` is not satisfied +} + +fn main() {} diff --git a/tests/ui/traits/next-solver/diagnostics/where-clause-doesnt-apply.stderr b/tests/ui/traits/next-solver/diagnostics/where-clause-doesnt-apply.stderr new file mode 100644 index 00000000000..77a0cc49754 --- /dev/null +++ b/tests/ui/traits/next-solver/diagnostics/where-clause-doesnt-apply.stderr @@ -0,0 +1,22 @@ +error[E0277]: the trait bound `(): Foo` is not satisfied + --> $DIR/where-clause-doesnt-apply.rs:18:15 + | +LL | needs_foo(()); + | --------- ^^ the trait `Bar` is not implemented for `()`, which is required by `(): Foo` + | | + | required by a bound introduced by this call + | +note: required for `()` to implement `Foo` + --> $DIR/where-clause-doesnt-apply.rs:4:9 + | +LL | impl<T> Foo for T where T: Bar {} + | ^^^ ^ --- unsatisfied trait bound introduced here +note: required by a bound in `needs_foo` + --> $DIR/where-clause-doesnt-apply.rs:5:22 + | +LL | fn needs_foo(_: impl Foo) {} + | ^^^ required by this bound in `needs_foo` + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0277`. |
