-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Improve "self" errors a bit #54369
Comments
Label emitted in the following two places rust/src/librustc_resolve/lib.rs Lines 3024 to 3025 in 3bc2ca7
The easiest change is rewording as proposed. A harder change would be to make it context dependent and figure out wether it is in happening in a |
Hi, I took an easy path and implemented #54495. If you dislike this approach I can redo this, but It feels to me that taking context in account complicates things, plus I'm not sure about wording. |
Contexually dependent error message for E0424 when value is assigned to "self" This is an improvement for pull request rust-lang#54495 referencing issue rust-lang#54369. If the "self" keyword is assigned a value as though it were a valid identifier, it will now report: ``` let self = "self"; ^^^^ `self` value is a keyword and may not be bound to variables or shadowed ``` instead of ``` let self = "self"; ^^^^ `self` value is a keyword only available in methods with `self` parameter ``` If anyone has a better idea for what the error should be I'd be happy to modify it appropriately.
Contexually dependent error message for E0424 when value is assigned to "self" This is an improvement for pull request rust-lang#54495 referencing issue rust-lang#54369. If the "self" keyword is assigned a value as though it were a valid identifier, it will now report: ``` let self = "self"; ^^^^ `self` value is a keyword and may not be bound to variables or shadowed ``` instead of ``` let self = "self"; ^^^^ `self` value is a keyword only available in methods with `self` parameter ``` If anyone has a better idea for what the error should be I'd be happy to modify it appropriately.
Contexually dependent error message for E0424 when value is assigned to "self" This is an improvement for pull request rust-lang#54495 referencing issue rust-lang#54369. If the "self" keyword is assigned a value as though it were a valid identifier, it will now report: ``` let self = "self"; ^^^^ `self` value is a keyword and may not be bound to variables or shadowed ``` instead of ``` let self = "self"; ^^^^ `self` value is a keyword only available in methods with `self` parameter ``` If anyone has a better idea for what the error should be I'd be happy to modify it appropriately.
Contexually dependent error message for E0424 when value is assigned to "self" This is an improvement for pull request rust-lang#54495 referencing issue rust-lang#54369. If the "self" keyword is assigned a value as though it were a valid identifier, it will now report: ``` let self = "self"; ^^^^ `self` value is a keyword and may not be bound to variables or shadowed ``` instead of ``` let self = "self"; ^^^^ `self` value is a keyword only available in methods with `self` parameter ``` If anyone has a better idea for what the error should be I'd be happy to modify it appropriately.
Contexually dependent error message for E0424 when value is assigned to "self" This is an improvement for pull request #54495 referencing issue #54369. If the "self" keyword is assigned a value as though it were a valid identifier, it will now report: ``` let self = "self"; ^^^^ `self` value is a keyword and may not be bound to variables or shadowed ``` instead of ``` let self = "self"; ^^^^ `self` value is a keyword only available in methods with `self` parameter ``` If anyone has a better idea for what the error should be I'd be happy to modify it appropriately.
Currently it looks like this:
Rewording a bit like "
self
value is a keyword only available in methods withself
parameter" would read a bit better and would be more explicit.The text was updated successfully, but these errors were encountered: