Skip to content

Self with type aliases could emit a better error #93796

Closed
@lcnr

Description

@lcnr
type Foo<T>
where
    Self: Clone,
= Vec<T>;

results in

error[E0411]: cannot find type `Self` in this scope
 --> src/lib.rs:3:5
  |
3 |     Self: Clone,
  |     ^^^^ `Self` is only available in impls, traits, and type definitions

it may makes sense to add a "forbidden" rib to type aliases which contains Self and emits a better error for this or at least adds a note like "Self cannot be used to refer to type aliases"

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsT-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