From b8a7c6f5b611202598a14871c2d08e3bc6122196 Mon Sep 17 00:00:00 2001 From: Julian Kulesh Date: Sun, 23 Sep 2018 05:35:42 +0300 Subject: [PATCH] Improve error message for E0424 --- src/librustc_resolve/lib.rs | 6 ++++-- src/test/ui/error-codes/E0424.stderr | 2 +- src/test/ui/resolve/issue-2356.stderr | 8 ++++---- src/test/ui/resolve/unresolved_static_type_field.stderr | 2 +- 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/librustc_resolve/lib.rs b/src/librustc_resolve/lib.rs index 327eaacdf16..91b0e9c1dca 100644 --- a/src/librustc_resolve/lib.rs +++ b/src/librustc_resolve/lib.rs @@ -3009,7 +3009,8 @@ fn smart_resolve_path_fragment(&mut self, 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()); } @@ -3052,7 +3053,8 @@ fn smart_resolve_path_fragment(&mut self, 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")); } } diff --git a/src/test/ui/error-codes/E0424.stderr b/src/test/ui/error-codes/E0424.stderr index 2c4f7f7c62b..a1b7a5f6533 100644 --- a/src/test/ui/error-codes/E0424.stderr +++ b/src/test/ui/error-codes/E0424.stderr @@ -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 diff --git a/src/test/ui/resolve/issue-2356.stderr b/src/test/ui/resolve/issue-2356.stderr index 3e6c38bce51..8b261f76b89 100644 --- a/src/test/ui/resolve/issue-2356.stderr +++ b/src/test/ui/resolve/issue-2356.stderr @@ -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 @@ -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 @@ -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 @@ -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 diff --git a/src/test/ui/resolve/unresolved_static_type_field.stderr b/src/test/ui/resolve/unresolved_static_type_field.stderr index 262a4983b81..a49ea3d3bd5 100644 --- a/src/test/ui/resolve/unresolved_static_type_field.stderr +++ b/src/test/ui/resolve/unresolved_static_type_field.stderr @@ -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 -- GitLab