Skip to content

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

Closed
@hkmatsumoto

Description

@hkmatsumoto

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).

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

No branches or pull requests

Issue actions