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

Simple example of HRTB bound not resolving correctly #107699

Open
Swire42 opened this issue Feb 5, 2023 · 1 comment
Open

Simple example of HRTB bound not resolving correctly #107699

Swire42 opened this issue Feb 5, 2023 · 1 comment
Labels
A-higher-ranked Area: Higher-ranked things (e.g., lifetimes, types, trait bounds aka HRTBs) A-trait-system Area: Trait system C-bug Category: This is a bug. T-types Relevant to the types team, which will review and decide on the PR/issue.

Comments

@Swire42
Copy link

Swire42 commented Feb 5, 2023

I tried this code:

pub trait A {}
pub trait B where for<'a> &'a Self: A {}
pub trait C<X: B> {}
pub trait D<X: B> where for<'a> &'a X: A {}

I expected it to compile. However, while D works just fine, C produces the following error:

error[E0277]: the trait bound `for<'a> &'a X: A` is not satisfied
 --> src/lib.rs:3:16
  |
3 | pub trait C<X: B> {}
  |                ^ the trait `for<'a> A` is not implemented for `&'a X`
  |
note: required by a bound in `B`
 --> src/lib.rs:2:37
  |
2 | pub trait B where for<'a> &'a Self: A {}
  |                                     ^ required by this bound in `B`

For more information about this error, try `rustc --explain E0277`.

This fails in all versions currently available in playground.

My original use case was requiring an operator to be implemented on references.

@Swire42 Swire42 added the C-bug Category: This is a bug. label Feb 5, 2023
@SkiFire13
Copy link
Contributor

Looks like a duplicate of #20671

@fmease fmease added A-trait-system Area: Trait system T-types Relevant to the types team, which will review and decide on the PR/issue. and removed needs-triage-legacy labels Apr 17, 2024
@fmease fmease added the A-higher-ranked Area: Higher-ranked things (e.g., lifetimes, types, trait bounds aka HRTBs) label Sep 24, 2024
@fmease fmease added A-trait-system Area: Trait system and removed A-trait-system Area: Trait system labels Dec 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-higher-ranked Area: Higher-ranked things (e.g., lifetimes, types, trait bounds aka HRTBs) A-trait-system Area: Trait system C-bug Category: This is a bug. T-types Relevant to the types team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

4 participants