-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-suggestion-diagnosticsArea: Suggestions generated by the compiler applied by `cargo fix`Area: Suggestions generated by the compiler applied by `cargo fix`C-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
Forgetting to include the left-hand side of an arbitrary self type can give some confusing errors. This was reported by someone trying to implement a future manually, and the diagnostics threw them off.
I realize diagnostics for arbitrary self types are an open issue, but figured I'd include this variant as to not overlook it. Thanks!
Code
pub fn hello(Box<Self>) {}
Expected
error: expected one of `:` or `@`, found `<`
--> src/lib.rs:1:17
|
1 | pub fn hello(Box<Self>) {}
| ^
6BEA
expected one of `:` or `@` here
|
help: if this is a `self` type, give it a parameter name
|
1 | pub fn hello(self: Box<Self>) {}
| ^^^^^^^^^^^^^^^
error: aborting due to previous error
Current
error: expected one of `:` or `@`, found `<`
--> src/lib.rs:1:17
|
1 | pub fn hello(Box<Self>) {}
| ^ expected one of `:` or `@` here
error: aborting due to previous error
Hoverbear
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-suggestion-diagnosticsArea: Suggestions generated by the compiler applied by `cargo fix`Area: Suggestions generated by the compiler applied by `cargo fix`C-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.