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 error message for E0424 #54495

Merged
merged 1 commit into from
Sep 24, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/librustc_resolve/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3009,7 +3009,8 @@ impl<'a, 'crateloader: 'a> Resolver<'a, 'crateloader> {
if is_self_value(path, ns) {
__diagnostic_used!(E0424);
err.code(DiagnosticId::Error("E0424".into()));
err.span_label(span, format!("`self` value is only available in \
err.span_label(span, format!("`self` value is a keyword \
only available in \
methods with `self` parameter"));
return (err, Vec::new());
}
Expand Down Expand Up @@ -3052,7 +3053,8 @@ impl<'a, 'crateloader: 'a> Resolver<'a, 'crateloader> {
Applicability::MachineApplicable,
);
if !self_is_available {
err.span_label(span, format!("`self` value is only available in \
err.span_label(span, format!("`self` value is a keyword \
only available in \
methods with `self` parameter"));
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/error-codes/E0424.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ error[E0424]: expected value, found module `self`
--> $DIR/E0424.rs:17:9
|
LL | self.bar(); //~ ERROR E0424
| ^^^^ `self` value is only available in methods with `self` parameter
| ^^^^ `self` value is a keyword only available in methods with `self` parameter

error: aborting due to previous error

Expand Down
8 changes: 4 additions & 4 deletions src/test/ui/resolve/issue-2356.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ error[E0425]: cannot find value `whiskers` in this scope
LL | whiskers -= other;
| ^^^^^^^^
| |
| `self` value is only available in methods with `self` parameter
| `self` value is a keyword only available in methods with `self` parameter
| help: try: `self.whiskers`

error[E0425]: cannot find function `shave` in this scope
Expand Down Expand Up @@ -65,7 +65,7 @@ error[E0424]: expected value, found module `self`
--> $DIR/issue-2356.rs:75:8
|
LL | if self.whiskers > 3 {
| ^^^^ `self` value is only available in methods with `self` parameter
| ^^^^ `self` value is a keyword only available in methods with `self` parameter

error[E0425]: cannot find function `grow_older` in this scope
--> $DIR/issue-2356.rs:82:5
Expand All @@ -91,7 +91,7 @@ error[E0425]: cannot find value `whiskers` in this scope
LL | whiskers = 4;
| ^^^^^^^^
| |
| `self` value is only available in methods with `self` parameter
| `self` value is a keyword only available in methods with `self` parameter
| help: try: `self.whiskers`

error[E0425]: cannot find function `purr_louder` in this scope
Expand All @@ -104,7 +104,7 @@ error[E0424]: expected value, found module `self`
--> $DIR/issue-2356.rs:102:5
|
LL | self += 1;
| ^^^^ `self` value is only available in methods with `self` parameter
| ^^^^ `self` value is a keyword only available in methods with `self` parameter

error: aborting due to 17 previous errors

Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/resolve/unresolved_static_type_field.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ error[E0425]: cannot find value `cx` in this scope
LL | f(cx);
| ^^
| |
| `self` value is only available in methods with `self` parameter
| `self` value is a keyword only available in methods with `self` parameter
| help: try: `self.cx`

error: aborting due to previous error
Expand Down