Skip to content

suppress projection errors already covered by a trait error - #161088

Open
Albab-Hasan wants to merge 1 commit into
rust-lang:mainfrom
Albab-Hasan:suppress-duplicate-closure-output-error
Open

suppress projection errors already covered by a trait error#161088
Albab-Hasan wants to merge 1 commit into
rust-lang:mainfrom
Albab-Hasan:suppress-duplicate-closure-output-error

Conversation

@Albab-Hasan

Copy link
Copy Markdown
Contributor

under the next solver a closure whose signature doesnt match emits both the trait goal error and the <C as FnOnce<..>>::Output == .. projection error that falls out of that same failed unification. the suppression pass only compared trait goals against trait goals and projections against projections so it never saw a projection resting on a trait goal that already errored at the same span. suppress those. ambiguity errors are exempt. they get merged into one diagnostic listing every constraint.

one note. the suppressed error in iterator-item-suggest-no-ice carried a method chain note the surviving error doesnt have, so that case loses output and not just a duplicate.

follow up to #159839 (comment)

r? @oli-obk
cc @estebank

under the next solver a closure whose signature doesnt match emitted two errors at the same span. the trait goal `C: FnMut(&i32)` failed, and the `<C as FnOnce<..>>::Output == bool` projection goal resting on it failed out of that same unification. the old solver collapses both into a single `type mismatch in closure arguments`, so the projection error was noise.

suppress a projection error when another error at the same span is a trait goal it rests on. ambiguity errors are exempt, they get merged into one diagnostic whose notes list every constraint the annotation has to satisfy, so their projections still say something the trait error doesnt.
@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 Aug 14, 2026
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.

3 participants