Skip to content

Add note on attempts of using Self as a normal generic arg #89985

@hkmatsumoto

Description

@hkmatsumoto
Contributor

Given the following code: https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=53b02445623677643befa3e7dbe0f3b4

fn foo<Self>() {}

The current output is:

error: expected identifier, found keyword `Self`
 --> src/lib.rs:1:8
  |
1 | fn foo<Self>() {}
  |        ^^^^ expected identifier, found keyword

The diagnostic itself is right but confusing; it lacks why Self is a reserved keyword (IIUC it's because Self is special-cased to represent traits or ADTs in its implementations).

Activity

added
A-diagnosticsArea: Messages for errors, warnings, and lints
T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
on Oct 17, 2021
hkmatsumoto

hkmatsumoto commented on Oct 17, 2021

@hkmatsumoto
ContributorAuthor

@rustbot claim

added
D-newcomer-roadblockDiagnostics: Confusing error or lint; hard to understand for new users.
P-lowLow priority
on Oct 18, 2021
added a commit that references this issue on Dec 4, 2021
29fe57d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

A-diagnosticsArea: Messages for errors, warnings, and lintsD-newcomer-roadblockDiagnostics: Confusing error or lint; hard to understand for new users.P-lowLow priorityT-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

    Participants

    @hkmatsumoto

    Issue actions

      Add note on attempts of using `Self` as a normal generic arg · Issue #89985 · rust-lang/rust