Skip to content

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

Merged
rust-bors[bot] merged 3 commits into
rust-lang:mainfrom
Albab-Hasan:merge-ambiguity-errors
Aug 13, 2026
Merged

merge ambiguity errors that blame the same inference variable#159593
rust-bors[bot] merged 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
Member

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
Member

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
@khyperia

Copy link
Copy Markdown
Member

nice, thank you for your patience!

@bors r+

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

ahah thank you, I appreciate it! ❤️ - it's been a while since I've futzed around with my renderer, but it's great fun :3

@rust-bors

rust-bors Bot commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

📌 Commit 846d935 has been approved by khyperia

It is now in the queue for this repository.

@rust-bors rust-bors Bot added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Aug 13, 2026
rust-bors Bot pushed a commit that referenced this pull request Aug 13, 2026
Rollup of 8 pull requests

Successful merges:

 - #159593 (merge ambiguity errors that blame the same inference variable)
 - #160687 (Experiment: Add `core::cmp::smallest` and `core::cmp::largest`)
 - #160856 (Replace infers and non-rigid aliases with `Ty/Const::Error` if param env normalization fails)
 - #160961 (bootstrap: Overhaul matching of command-line selectors to steps)
 - #160975 (Remove target argument from get_proc_macros)
 - #161023 (bootstrap: Replace the `exit!` macro with a function `helpers::exit_process`)
 - #160932 (Make tidy::Version public)
 - #161029 (mailmap: Update my default email)
@rust-bors
rust-bors Bot merged commit 8fa3465 into rust-lang:main Aug 13, 2026
13 checks passed
rust-timer added a commit that referenced this pull request Aug 13, 2026
Rollup merge of #159593 - Albab-Hasan:merge-ambiguity-errors, r=khyperia

merge ambiguity errors that blame the same inference variable

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 this to the 1.99.0 milestone Aug 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. 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