Skip to content

rustc: trait-level where clauses are mistakenly imposed when bounding by the trait #50792

Closed
@aturon

Description

@aturon

I'm trying to use a where clause to define one trait in terms of another, as applied to a wrapper type:

struct Wrapper<T>(T);

trait Base {}
trait Wrapped: Sized where Wrapper<Self>: Base {}

fn wat<F: Wrapped>() {}

But when I try to bound by the new trait, I get a strange error:

error[E0277]: the trait bound `Wrapper<F>: Base` is not satisfied
 --> src/main.rs:7:1
  |
7 | fn wat<F: Wrapped>() {}
  | ^^^^^^^^^^^^^^^^^^^^^^^ the trait `Base` is not implemented for `Wrapper<F>`
  |
note: required by `Wrapped`
 --> src/main.rs:5:1
  |
5 | trait Wrapped: Sized where Wrapper<Self>: Base {}
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-trait-systemArea: Trait systemC-bugCategory: This is a bug.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions