Skip to content

Don't merge distinct impl candidates - #161386

Open
bit-aloo wants to merge 3 commits into
rust-lang:mainfrom
bit-aloo:2026-08-17-merge-impls
Open

Don't merge distinct impl candidates#161386
bit-aloo wants to merge 3 commits into
rust-lang:mainfrom
bit-aloo:2026-08-17-merge-impls

Conversation

@bit-aloo

Copy link
Copy Markdown
Member

@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 20, 2026
@bit-aloo

Copy link
Copy Markdown
Member Author

I am not very confident about fallout bless's: 994cca7

@rust-log-analyzer

This comment has been minimized.

trait_def_id: I::TraitId,
candidates: &[Candidate<I>],
) -> Option<(CanonicalResponse<I>, MergeCandidateInfo)> {
let mut impls = candidates.iter().filter(|c| matches!(c.source, CandidateSource::Impl(_)));

@lcnr lcnr Aug 20, 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.

should do the same with builtin impls 😁

View changes since the review

// remaining candidates.
let proven_via = if candidates
.iter()
.all(|c| matches!(c.source, CandidateSource::ParamEnv(ParamEnvSource::Global)))

@lcnr lcnr Aug 20, 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.

effectively this match is a check whether we should merge candidates or not 😁

because these are all either impl, builtin impl, or global where-bounds

View changes since the review

if impls.nth(1).is_some() && !self.cx().trait_is_marker(trait_def_id) {
return None;
}
self.try_merge_candidates(candidates)

@lcnr lcnr Aug 20, 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.

why do we need to call try_merge_candidates if impls are Some?

View changes since the review

@lcnr

lcnr commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

this fails to bootstrap, probably something related to specialization 🤔 😁 please minimize and look into why

@rust-cloud-vms
rust-cloud-vms Bot force-pushed the 2026-08-17-merge-impls branch from 994cca7 to 36d20a8 Compare August 20, 2026 07:53
@rust-log-analyzer

Copy link
Copy Markdown
Collaborator

The job x86_64-gnu-next-trait-solver-polonius failed! Check out the build log: (web) (plain enhanced) (plain)

Click to see the possible cause of the failure (guessed by this bot)
    |
275 |         let len = ZipImpl::size_hint(&self).0;
    |                   ^^^^^^^^^^^^^^^^^^ ----- type must be known at this point
    |                   |
    |                   cannot infer type of the type parameter `A` declared on the trait `ZipImpl`
    |
note: multiple `impl`s satisfying `Zip<A, B>: ZipImpl<_, _>` found
   --> library/core/src/iter/adapters/zip.rs:206:1
    |
206 | / impl<A, B> ZipImpl<A, B> for Zip<A, B>
207 | | where
208 | |     A: Iterator,
209 | |     B: Iterator,
    | |________________^
...
248 | / impl<A, B> ZipImpl<A, B> for Zip<A, B>
249 | | where
250 | |     A: TrustedRandomAccessNoCoerce + Iterator,
251 | |     B: TrustedRandomAccessNoCoerce + Iterator,
    | |______________________________________________^
help: consider specifying the generic arguments
    |
275 |         let len = ZipImpl::<A, B>::size_hint(&self).0;
    |                          ++++++++

error[E0283]: type annotations needed
   --> library/core/src/iter/adapters/zip.rs:281:39
    |
281 |                 accum = f(accum, self.get_unchecked(i));
    |                                       ^^^^^^^^^^^^^
    |
note: multiple `impl`s satisfying `Zip<A, B>: ZipImpl<_, _>` found
   --> library/core/src/iter/adapters/zip.rs:206:1
    |
206 | / impl<A, B> ZipImpl<A, B> for Zip<A, B>
207 | | where
208 | |     A: Iterator,
209 | |     B: Iterator,
    | |________________^
...
248 | / impl<A, B> ZipImpl<A, B> for Zip<A, B>
249 | | where
250 | |     A: TrustedRandomAccessNoCoerce + Iterator,
251 | |     B: TrustedRandomAccessNoCoerce + Iterator,
    | |______________________________________________^
help: try using a fully qualified path to specify the expected types
    |
281 -                 accum = f(accum, self.get_unchecked(i));
281 +                 accum = f(accum, <Zip<A, B> as ZipImpl<A, B>>::get_unchecked(&mut self, i));
    |

For more information about this error, try `rustc --explain E0283`.
[RUSTC-TIMING] core test:false 20.128
error: could not compile `core` (lib) due to 2 previous errors

Important

For more information how to resolve CI failures of this job, visit this link.

@lcnr

lcnr commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

@rustbot author

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

Labels

S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. 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.

overlapping impl candidates are no longer an error

4 participants