Skip to content

Commit 8a92ebf

Browse files
committed
Auto merge of #54495 - raventid:improve-e0425-message, r=estebank
Improve error message for E0424 Resolves #54369 r? @estebank
2 parents d4c6f40 + b8a7c6f commit 8a92ebf

File tree

4 files changed

+10
-8
lines changed

4 files changed

+10
-8
lines changed

src/librustc_resolve/lib.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -3009,7 +3009,8 @@ impl<'a, 'crateloader: 'a> Resolver<'a, 'crateloader> {
30093009
if is_self_value(path, ns) {
30103010
__diagnostic_used!(E0424);
30113011
err.code(DiagnosticId::Error("E0424".into()));
3012-
err.span_label(span, format!("`self` value is only available in \
3012+
err.span_label(span, format!("`self` value is a keyword \
3013+
only available in \
30133014
methods with `self` parameter"));
30143015
return (err, Vec::new());
30153016
}
@@ -3052,7 +3053,8 @@ impl<'a, 'crateloader: 'a> Resolver<'a, 'crateloader> {
30523053
Applicability::MachineApplicable,
30533054
);
30543055
if !self_is_available {
3055-
err.span_label(span, format!("`self` value is only available in \
3056+
err.span_label(span, format!("`self` value is a keyword \
3057+
only available in \
30563058
methods with `self` parameter"));
30573059
}
30583060
}

src/test/ui/error-codes/E0424.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error[E0424]: expected value, found module `self`
22
--> $DIR/E0424.rs:17:9
33
|
44
LL | self.bar(); //~ ERROR E0424
5-
| ^^^^ `self` value is only available in methods with `self` parameter
5+
| ^^^^ `self` value is a keyword only available in methods with `self` parameter
66

77
error: aborting due to previous error
88

src/test/ui/resolve/issue-2356.stderr

+4-4
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ error[E0425]: cannot find value `whiskers` in this scope
2222
LL | whiskers -= other;
2323
| ^^^^^^^^
2424
| |
25-
| `self` value is only available in methods with `self` parameter
25+
| `self` value is a keyword only available in methods with `self` parameter
2626
| help: try: `self.whiskers`
2727

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

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

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

109109
error: aborting due to 17 previous errors
110110

src/test/ui/resolve/unresolved_static_type_field.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ error[E0425]: cannot find value `cx` in this scope
44
LL | f(cx);
55
| ^^
66
| |
7-
| `self` value is only available in methods with `self` parameter
7+
| `self` value is a keyword only available in methods with `self` parameter
88
| help: try: `self.cx`
99

1010
error: aborting due to previous error

0 commit comments

Comments
 (0)