Skip to content

merge ambiguity errors that blame the same inference variable - #159593

Open
Albab-Hasan wants to merge 3 commits into
rust-lang:mainfrom
Albab-Hasan:merge-ambiguity-errors
Open

merge ambiguity errors that blame the same inference variable#159593
Albab-Hasan wants to merge 3 commits into
rust-lang:mainfrom
Albab-Hasan:merge-ambiguity-errors

Conversation

@Albab-Hasan

Copy link
Copy Markdown
Contributor

multiple FulfillmentErrorCode::Ambiguity obligations on the same inference variable only ever reported the first. the rest got dropped after set_tainted_by_errors fired. grouped them by sub-unification-table root and fold Trait/Projection predicates from the group into notes on the primary. uses the sub root not the raw TyVid so variables unified by a pending Coerce obligation correctly land in the same group.

fixes #103911

r? @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 Jul 20, 2026
@lcnr

lcnr commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

looks vaguely good to me, gonna reassign though as I don't have the capacity to properly review this rn

@rustbot reroll

@rustbot rustbot assigned jackh726 and unassigned lcnr Jul 20, 2026
@rust-log-analyzer

This comment has been minimized.

@Albab-Hasan

Copy link
Copy Markdown
Contributor Author

@jackh726 i think this is causing the failure:

#157747

@lcnr lcnr closed this Jul 20, 2026
@rustbot rustbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jul 20, 2026
@lcnr lcnr reopened this Jul 20, 2026
@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jul 20, 2026
@Albab-Hasan

Copy link
Copy Markdown
Contributor Author

@jackh726 hello, just wanted to follow up on the pr. sorry if this is bothering you

@Albab-Hasan

Copy link
Copy Markdown
Contributor Author

@rustbot reroll

@rustbot rustbot assigned khyperia and unassigned jackh726 Aug 6, 2026
LL - x.foo();
LL + <Vec<T> as Foo>::foo(&x);
|

@khyperia khyperia Aug 6, 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.

I haven't dug at all into the change itself yet, but e.g. this diff seems unfortunate. Is it possible to keep mentioning the impls and whatnot here?

View changes since the review

@rust-bors

This comment has been minimized.

@Albab-Hasan
Albab-Hasan force-pushed the merge-ambiguity-errors branch from 578ea93 to ca47683 Compare August 12, 2026 04:11
@rustbot

This comment has been minimized.

@rust-bors

This comment has been minimized.

multiple `FulfillmentErrorCode::Ambiguity` obligations on the same
inference variable only ever reported the first — the rest got dropped
after `set_tainted_by_errors` fired. grouped them by sub-unification-table
root and fold Trait/Projection predicates from the group into notes on the
primary. uses the sub root not the raw TyVid so variables unified by a
pending Coerce obligation correctly land in the same group.

fixes rust-lang#103911
@Albab-Hasan
Albab-Hasan force-pushed the merge-ambiguity-errors branch from ca47683 to e27cb9b Compare August 12, 2026 08:12
@rustbot

rustbot commented Aug 12, 2026

Copy link
Copy Markdown
Collaborator

This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

help: consider specifying a concrete type for the type parameter `S`
|
LL | println!("{}", 23u64.test(xs.iter().sum::</* Type */>()));
| ++++++++++++++

@khyperia khyperia Aug 12, 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.

sorry for being slow to review! very swamped with other stuff right now :s

dropping this kind of thing from the output seems unfortunate too. From my understanding of reading the PR description of:

the rest got dropped after set_tainted_by_errors fired

my feeling is that we should generally only be adding information to errors in this PR, not dropping additional errors we were emitting before. Mmmmayyybe it's fine to drop errors like this that actually are from the same inference variable, but the information on these dropped errors should probably migrate to an actually emitted error.

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.

np, im just glad this pr is getting reviewed lol :) rlly appreciate the review!

agree, that shouldnt be dropped. errors blaming a different span keep their own error now, and the merged ones carry their notes over.

btw not to be the github profile lurker here but the fractals on ur website are lowkey insane

an error pointing at a different expression labels that expression and suggests how to annotate
it, and a note on the merged diagnostic carries none of that, so it kept getting dropped. such
errors are reported on their own again, and the bounds behind the errors that do get merged are
now explained on the merged diagnostic.
@Albab-Hasan
Albab-Hasan requested a review from khyperia August 12, 2026 14:36
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.

improve the way we deal with ambiguity errors

6 participants