Skip to content

Confusing error message when using Self in where clause bounds errornously #50871

@Havvy

Description

@Havvy

The source trait SelfReferential<T> where T: Self {} gives the error

error[E0411]: expected trait, found self type `Self`
  --> src/main.rs:13:35
   |
13 | trait SelfReferential<T> where T: Self {}
   |                                   ^^^^ `Self` is only available in traits and impls

This is confusing because the Self is in a trait. It just doesn't seem to be valid to use it as the trait bounds of a type in a where clause.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsA-trait-systemArea: Trait systemC-enhancementCategory: An issue proposing an enhancement or a PR with one.D-papercutDiagnostics: An error or lint that needs small tweaks.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions