Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Comparisons with concrete types break in the presence of inapplicable where bounds #95777

Closed
robertbastian opened this issue Apr 7, 2022 · 3 comments
Labels
A-trait-system Area: Trait system C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@robertbastian
Copy link
Contributor

See https://play.rust-lang.org/?version=nightly&mode=debug&edition=2021&gist=f6449d0fee6e0875b3f92612a5be84bd

@robertbastian robertbastian added the C-bug Category: This is a bug. label Apr 7, 2022
@compiler-errors
Copy link
Member

This is probably due to SelectionContext::candidate_should_be_dropped_in_favor_of preferring param-env candidates (in the where-clause) over impl candidates.

The reason that &1u8 == &2u8 works in the first function's first line is that this impl candidate applies first when we have &_ compared to &_ and doesn't overlap with the param-env candidate.

@compiler-errors
Copy link
Member

compiler-errors commented Apr 7, 2022

Not exactly sure how to fix this without either:

  1. adjusting the logic here, but I would expect that to have fallout in many other places
  2. doing some hacks to infer the real types of the generic arguments we pass to, e.g., <_ as Add<_>>::add, but I fear that would mess with coercions that are used to, e.g., let us do String + &String even without an impl that matches this signature exactly (i.e. coercing into this impl)

@fmease fmease added A-trait-system Area: Trait system T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. and removed needs-triage-legacy labels Jan 24, 2024
@fmease
Copy link
Member

fmease commented Jan 24, 2024

Closing as duplicate of #24066 similar to #84218.

@fmease fmease closed this as not planned Won't fix, can't repro, duplicate, stale Jan 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-trait-system Area: Trait system C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

4 participants