Skip to content

Self with type aliases could emit a better error #93796

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

Closed
lcnr opened this issue Feb 9, 2022 · 0 comments · Fixed by #98274
Closed

Self with type aliases could emit a better error #93796

lcnr opened this issue Feb 9, 2022 · 0 comments · Fixed by #98274
Labels
A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@lcnr
Copy link
Contributor

lcnr commented Feb 9, 2022

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"

@lcnr lcnr added A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Feb 9, 2022
@bors bors closed this as completed in 1888499 Jun 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant