Skip to content
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

Closed
GuillaumeGomez opened this issue Sep 19, 2018 · 2 comments
Closed

Improve "self" errors a bit #54369

GuillaumeGomez opened this issue Sep 19, 2018 · 2 comments
Labels
A-diagnostics Area: Messages for errors, warnings, and lints E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. E-help-wanted Call for participation: Help is requested to fix this issue. E-mentor Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.

Comments

@GuillaumeGomez
Copy link
Member

Currently it looks like this:

let self = process_queue.self();
    ^^^^ `self` value is only available in methods with `self` parameter

Rewording a bit like "self value is a keyword only available in methods with self parameter" would read a bit better and would be more explicit.

@GuillaumeGomez GuillaumeGomez added the A-diagnostics Area: Messages for errors, warnings, and lints label Sep 19, 2018
@estebank
Copy link
Contributor

Label emitted in the following two places

err.span_label(span, format!("`self` value is only available in \
methods with `self` parameter"));

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 let binding to provide a more tailored message.

@estebank estebank added E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. E-mentor Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion. E-help-wanted Call for participation: Help is requested to fix this issue. labels Sep 20, 2018
@raventid
Copy link
Contributor

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.

bors added a commit that referenced this issue Sep 24, 2018
pietroalbini added a commit to pietroalbini/rust that referenced this issue Dec 11, 2018
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.
kennytm added a commit to kennytm/rust that referenced this issue Dec 12, 2018
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.
pietroalbini added a commit to pietroalbini/rust that referenced this issue Dec 12, 2018
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.
kennytm added a commit to kennytm/rust that referenced this issue Dec 14, 2018
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.
bors added a commit that referenced this issue Dec 14, 2018
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. E-help-wanted Call for participation: Help is requested to fix this issue. E-mentor Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.
Projects
None yet
Development

No branches or pull requests

3 participants