Skip to content

Silence redundant failed obligations on the same statement - #163913

Open
estebank wants to merge 4 commits into
rust-lang:mainfrom
estebank:wellformedloc
Open

estebank wants to merge 4 commits into
rust-lang:mainfrom
estebank:wellformedloc

Conversation

@estebank

@estebank estebank commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

Fix #84346, fix #105753.

On multiple unment obligations in the same method chain, only emit one. On unmet Sized obligations on a binding, its type and its init expression, only emit one.

Carry more information for well-formed obligations coming from expressions.
@rustbot

rustbot commented Oct 7, 2026

Copy link
Copy Markdown
Collaborator

changes to the core type system

cc @lcnr

@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. WG-trait-system-refactor The Rustc Trait System Refactor Initiative (-Znext-solver) labels Oct 7, 2026
@rustbot

rustbot commented Oct 7, 2026

Copy link
Copy Markdown
Collaborator

r? @oli-obk

rustbot has assigned @oli-obk.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: compiler
  • compiler expanded to 77 candidates
  • Random selection from 19 candidates

@rust-log-analyzer

This comment has been minimized.

@estebank

estebank commented Oct 7, 2026

Copy link
Copy Markdown
Contributor Author

Easier to review per-comit: first add mild mechanic changes to have more tracking to be used later, added the tests that I wanted to tackle, and finally the actual logic change that affects the emitted errors.

@oli-obk oli-obk changed the title Silence redudant failed obligations on the same statement Silence redundant failed obligations on the same statement Oct 7, 2026
Comment thread compiler/rustc_hir_typeck/src/expr.rs Outdated
field_ty,
expr.span,
ObligationCauseCode::Misc,
ObligationCauseCode::WellFormed(WellFormedLoc::None),

@oli-obk oli-obk Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

may be worth figuring out a WellFormedLoc for, as this is the only use of None that won't be removed when the old solver gets nuked Soon ™️

View changes since the review

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using the HirId of the expr doesn't change anything today (because it is the offset_of! macro which already points at the whole expr), but might in the future. Changed in the last commit.

Comment thread compiler/rustc_infer/src/infer/mod.rs
Comment thread compiler/rustc_trait_selection/src/error_reporting/traits/fulfillment_errors.rs Outdated
Comment thread compiler/rustc_trait_selection/src/error_reporting/traits/fulfillment_errors.rs Outdated
@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Oct 7, 2026
@rustbot

rustbot commented Oct 7, 2026

Copy link
Copy Markdown
Collaborator

Reminder, once the PR becomes ready for a review, use @rustbot ready.

Reduces the number of errors being emitted by a single unmet `Sized` (or other) bound in method call chains.
@estebank estebank added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Oct 7, 2026

This branch has not been deployed

No deployments
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.

Too many dyn Trait is not Sized errors Provide suggestions for unsized type parameters and when involving iterators

4 participants