about summary refs log tree commit diff
path: root/src/test/ui/error-codes
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2018-12-14 20:36:12 +0000
committerbors <bors@rust-lang.org>2018-12-14 20:36:12 +0000
commit96d1334e567237b1507cd277938e7ae2de75ff51 (patch)
treefe65d9a14a288c1ae63fb45ac2a59030646d5646 /src/test/ui/error-codes
parent1897657ef09eea3d0b0afbbbd154a12fbb8fbf3f (diff)
parent9de6beeae28841d7a8b6bc06d6b66a30c723939d (diff)
downloadrust-96d1334e567237b1507cd277938e7ae2de75ff51.tar.gz
rust-96d1334e567237b1507cd277938e7ae2de75ff51.zip
Auto merge of #56572 - kevgrasso:let_self_err_dev, r=estebank
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.
Diffstat (limited to 'src/test/ui/error-codes')
-rw-r--r--src/test/ui/error-codes/E0424.rs1
-rw-r--r--src/test/ui/error-codes/E0424.stderr8
2 files changed, 8 insertions, 1 deletions
diff --git a/src/test/ui/error-codes/E0424.rs b/src/test/ui/error-codes/E0424.rs
index 445d0c5f3ed..20d42da1c0c 100644
--- a/src/test/ui/error-codes/E0424.rs
+++ b/src/test/ui/error-codes/E0424.rs
@@ -19,4 +19,5 @@ impl Foo {
 }
 
 fn main () {
+    let self = "self"; //~ ERROR E0424
 }
diff --git a/src/test/ui/error-codes/E0424.stderr b/src/test/ui/error-codes/E0424.stderr
index a1b7a5f6533..5eccd7d2283 100644
--- a/src/test/ui/error-codes/E0424.stderr
+++ b/src/test/ui/error-codes/E0424.stderr
@@ -4,6 +4,12 @@ error[E0424]: expected value, found module `self`
 LL |         self.bar(); //~ ERROR E0424
    |         ^^^^ `self` value is a keyword only available in methods with `self` parameter
 
-error: aborting due to previous error
+error[E0424]: expected unit struct/variant or constant, found module `self`
+  --> $DIR/E0424.rs:22:9
+   |
+LL |     let self = "self"; //~ ERROR E0424
+   |         ^^^^ `self` value is a keyword and may not be bound to variables or shadowed
+
+error: aborting due to 2 previous errors
 
 For more information about this error, try `rustc --explain E0424`.