-
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 lintsT-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
Code
struct Foo;
impl Foo {
fn do_something(self: Box<self>) -> Box<self> {
self
}
}
Current output
Compiling playground v0.0.1 (/playground)
error[E0435]: attempt to use a non-constant value in a constant
--> src/lib.rs:4:31
|
4 | fn do_something(self: Box<self>) -> Box<self> {
| ---- ^^^^
| |
| this would need to be a `const`
error[E0435]: attempt to use a non-constant value in a constant
--> src/lib.rs:4:45
|
4 | fn do_something(self: Box<self>) -> Box<self> {
| ---- ^^^^
| |
| this would need to be a `const`
For more information about this error, try `rustc --explain E0435`.
error: could not compile `playground` due to 2 previous errors
Desired output
Instead, rustc should suggest a change from `self` to `Self`, I think there is no case where `self` can appear like that in arguments or return type as it isn’t a type, but the current error message is definitely not clear to a newbie.
Rationale and extra context
No response
Other cases
No response
Anything else?
No response
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsT-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.