Skip to content

Retain TypeRelating errors in nested goals for BestObligationVisitor:: non_trivial_candidates - #162443

Open
LorrensP-2158466 wants to merge 2 commits into
rust-lang:mainfrom
LorrensP-2158466:fix-best-obligation-visitor
Open

Retain TypeRelating errors in nested goals for BestObligationVisitor:: non_trivial_candidates #162443
LorrensP-2158466 wants to merge 2 commits into
rust-lang:mainfrom
LorrensP-2158466:fix-best-obligation-visitor

Conversation

@LorrensP-2158466

@LorrensP-2158466 LorrensP-2158466 commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

When getting the non_trivial_candidates, also consider candidates whose nested candidates have a TypeRelating failure as well, instead of only impl-where clauses.

Should fix #161882
related: #t-types/call-for-participation > diagnostics proof tree visitor is too eager

r? @lcnr

@rustbot

rustbot commented Sep 7, 2026

Copy link
Copy Markdown
Collaborator

Some changes occurred to the core trait solver

cc @rust-lang/initiative-trait-system-refactor

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Sep 7, 2026
@rustbot rustbot added the WG-trait-system-refactor The Rustc Trait System Refactor Initiative (-Znext-solver) label Sep 7, 2026
@rust-log-analyzer

Copy link
Copy Markdown
Collaborator

The job test-aarch64-gnu-llvm-21-1 failed! Check out the build log: (web) (plain enhanced) (plain)

Click to see the possible cause of the failure (guessed by this bot)
test [ui] tests/ui/zero-sized/zero-sized-btreemap-insert.rs ... ok

failures:

---- [ui] tests/ui/traits/next-solver/confusing-diagnostic-due-to-best-obligation-visitor.rs stdout ----
Saved the actual stderr to `/checkout/obj/build/aarch64-unknown-linux-gnu/test/ui/traits/next-solver/confusing-diagnostic-due-to-best-obligation-visitor/confusing-diagnostic-due-to-best-obligation-visitor.stderr`
diff of stderr:

1 error[E0277]: the trait bound `MyError: From<<A as MaybeFallible>::Error>` is not satisfied
-   --> $DIR/issue-161882.rs:21:49
+   --> $DIR/confusing-diagnostic-due-to-best-obligation-visitor.rs:22:49
3    |
4 LL |     <A::Error as MaybeError>::ComposeWithOther: From<B>,
5    |                                                 ^^^^^^^ unsatisfied trait bound

6    |
7 help: the trait `From<<A as MaybeFallible>::Error>` is not implemented for `MyError`
-   --> $DIR/issue-161882.rs:6:1
+   --> $DIR/confusing-diagnostic-due-to-best-obligation-visitor.rs:7:1
9    |
10 LL | struct MyError;
11    | ^^^^^^^^^^^^^^
---
16    |       ---------- required by a bound in this trait

23    |                                                          ++++++++++++++++++++++++++++++++++++++++++
24 
25 error[E0277]: the trait bound `MyError: From<<Self as MaybeFallible>::Error>` is not satisfied
-   --> $DIR/issue-161882.rs:9:17
+   --> $DIR/confusing-diagnostic-due-to-best-obligation-visitor.rs:10:17
27    |
28 LL |     type Error: MaybeError;
29    |                 ^^^^^^^^^^ unsatisfied trait bound

30    |
31 help: the trait `From<<Self as MaybeFallible>::Error>` is not implemented for `MyError`
-   --> $DIR/issue-161882.rs:6:1
+   --> $DIR/confusing-diagnostic-due-to-best-obligation-visitor.rs:7:1
33    |
34 LL | struct MyError;
35    | ^^^^^^^^^^^^^^
---
40    |       ---------- required by a bound in this trait

43    |              ^^^^^^^^^^ required by this bound in `MaybeError`
44 
45 error[E0277]: the trait bound `MyError: From<<Self as MaybeError>::ComposeWithOther>` is not satisfied
-   --> $DIR/issue-161882.rs:16:28
+   --> $DIR/confusing-diagnostic-due-to-best-obligation-visitor.rs:17:28
47    |
48 LL |     type ComposeWithOther: MaybeError;
49    |                            ^^^^^^^^^^ unsatisfied trait bound

50    |
51 help: the trait `From<<Self as MaybeError>::ComposeWithOther>` is not implemented for `MyError`
-   --> $DIR/issue-161882.rs:6:1
+   --> $DIR/confusing-diagnostic-due-to-best-obligation-visitor.rs:7:1
53    |
54 LL | struct MyError;
55    | ^^^^^^^^^^^^^^
---
To only update this specific test, also pass `--test-args traits/next-solver/confusing-diagnostic-due-to-best-obligation-visitor.rs`

error: 1 errors occurred comparing output.
status: exit status: 1
command: env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/tests/ui/traits/next-solver/confusing-diagnostic-due-to-best-obligation-visitor.rs" "-Zsimulate-remapped-rust-src-base=/rustc/FAKE_PREFIX" "-Ztranslate-remapped-path-to-local-path=no" "-Z" "ignore-directory-in-diagnostics-source-blocks=/cargo" "-Z" "ignore-directory-in-diagnostics-source-blocks=/checkout/vendor" "--sysroot" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2" "--target=aarch64-unknown-linux-gnu" "--check-cfg" "cfg(test,FALSE)" "--error-format" "json" "--json" "future-incompat" "-Ccodegen-units=1" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Zwrite-long-types-to-disk=no" "-Cstrip=debuginfo" "--emit" "metadata" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/aarch64-unknown-linux-gnu/test/ui/traits/next-solver/confusing-diagnostic-due-to-best-obligation-visitor" "-Znext-solver=coherence" "-A" "unused" "-W" "unused_attributes" "-A" "internal_features" "-A" "incomplete_features" "-A" "unused_parens" "-A" "unused_braces" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/aarch64-unknown-linux-gnu/native/rust-test-helpers" "-Znext-solver=globally"
stdout: none
--- stderr -------------------------------
error[E0277]: the trait bound `MyError: From<<A as MaybeFallible>::Error>` is not satisfied
##[error]  --> /checkout/tests/ui/traits/next-solver/confusing-diagnostic-due-to-best-obligation-visitor.rs:22:49
   |
LL |     <A::Error as MaybeError>::ComposeWithOther: From<B>, //~ ERROR: the trait bound `MyError: From<<A as MaybeFallible>::Error>` is ...
   |                                                 ^^^^^^^ unsatisfied trait bound
   |
help: the trait `From<<A as MaybeFallible>::Error>` is not implemented for `MyError`
  --> /checkout/tests/ui/traits/next-solver/confusing-diagnostic-due-to-best-obligation-visitor.rs:7:1
   |
LL | struct MyError;
   | ^^^^^^^^^^^^^^
note: required by a bound in `MaybeError`
  --> /checkout/tests/ui/traits/next-solver/confusing-diagnostic-due-to-best-obligation-visitor.rs:15:14
   |
LL | trait MaybeError: Sized
   |       ---------- required by a bound in this trait
LL | where
LL |     MyError: From<Self>,
   |              ^^^^^^^^^^ required by this bound in `MaybeError`
help: consider extending the `where` clause, but there might be an alternative better way to express this requirement
   |
LL |     <A::Error as MaybeError>::ComposeWithOther: From<B>, MyError: From<<A as MaybeFallible>::Error> //~ ERROR: the trait bound `MyError: From<<A as MaybeFallible>::Error>` is not satisfied
   |                                                          ++++++++++++++++++++++++++++++++++++++++++

error[E0277]: the trait bound `MyError: From<<Self as MaybeFallible>::Error>` is not satisfied
##[error]  --> /checkout/tests/ui/traits/next-solver/confusing-diagnostic-due-to-best-obligation-visitor.rs:10:17
   |
LL |     type Error: MaybeError; //~ ERROR: the trait bound `MyError: From<<Self as MaybeFallible>::Error>` is not satisfied
   |                 ^^^^^^^^^^ unsatisfied trait bound
   |
help: the trait `From<<Self as MaybeFallible>::Error>` is not implemented for `MyError`
  --> /checkout/tests/ui/traits/next-solver/confusing-diagnostic-due-to-best-obligation-visitor.rs:7:1
   |
LL | struct MyError;
   | ^^^^^^^^^^^^^^
note: required by a bound in `MaybeError`
  --> /checkout/tests/ui/traits/next-solver/confusing-diagnostic-due-to-best-obligation-visitor.rs:15:14
   |
LL | trait MaybeError: Sized
   |       ---------- required by a bound in this trait
LL | where
LL |     MyError: From<Self>,
   |              ^^^^^^^^^^ required by this bound in `MaybeError`

error[E0277]: the trait bound `MyError: From<<Self as MaybeError>::ComposeWithOther>` is not satisfied
##[error]  --> /checkout/tests/ui/traits/next-solver/confusing-diagnostic-due-to-best-obligation-visitor.rs:17:28
   |
LL |     type ComposeWithOther: MaybeError; //~ ERROR: the trait bound `MyError: From<<Self as MaybeError>::ComposeWithOther>` is not sat...
   |                            ^^^^^^^^^^ unsatisfied trait bound
   |
help: the trait `From<<Self as MaybeError>::ComposeWithOther>` is not implemented for `MyError`
  --> /checkout/tests/ui/traits/next-solver/confusing-diagnostic-due-to-best-obligation-visitor.rs:7:1
   |
LL | struct MyError;
   | ^^^^^^^^^^^^^^
note: required by a bound in `MaybeError`
  --> /checkout/tests/ui/traits/next-solver/confusing-diagnostic-due-to-best-obligation-visitor.rs:15:14
   |
LL | trait MaybeError: Sized
   |       ---------- required by a bound in this trait
LL | where
LL |     MyError: From<Self>,
   |              ^^^^^^^^^^ required by this bound in `MaybeError`

error: aborting due to 3 previous errors

For more information about this error, try `rustc --explain E0277`.
------------------------------------------

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. WG-trait-system-refactor The Rustc Trait System Refactor Initiative (-Znext-solver)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Nightly shows confusing diagnostics mentioning ZeroablePrimitive without apparent reason

4 participants