about summary refs log tree commit diff
path: root/src/test/ui/error-codes
diff options
context:
space:
mode:
authorEsteban Küber <esteban@kuber.com.ar>2020-09-11 13:47:33 -0700
committerEsteban Küber <esteban@kuber.com.ar>2020-09-11 13:47:33 -0700
commit21f8326cec03848368e02936a032103aa24cf6d2 (patch)
tree7ea59c4dd393a16af87ae4f1e5f73cc06de37ae7 /src/test/ui/error-codes
parentd778203da2157f47af6d1f7ba5f44eb933ee2df1 (diff)
downloadrust-21f8326cec03848368e02936a032103aa24cf6d2.tar.gz
rust-21f8326cec03848368e02936a032103aa24cf6d2.zip
Provide suggestion for missing fields in patterns
Diffstat (limited to 'src/test/ui/error-codes')
-rw-r--r--src/test/ui/error-codes/E0027-teach.rs15
-rw-r--r--src/test/ui/error-codes/E0027-teach.stderr11
-rw-r--r--src/test/ui/error-codes/E0027.rs6
-rw-r--r--src/test/ui/error-codes/E0027.stderr26
4 files changed, 29 insertions, 29 deletions
diff --git a/src/test/ui/error-codes/E0027-teach.rs b/src/test/ui/error-codes/E0027-teach.rs
deleted file mode 100644
index 11402f01484..00000000000
--- a/src/test/ui/error-codes/E0027-teach.rs
+++ /dev/null
@@ -1,15 +0,0 @@
-// compile-flags: -Z teach
-
-struct Dog {
-    name: String,
-    age: u32,
-}
-
-fn main() {
-    let d = Dog { name: "Rusty".to_string(), age: 8 };
-
-    match d {
-        Dog { age: x } => {}
-        //~^ ERROR pattern does not mention field `name`
-    }
-}
diff --git a/src/test/ui/error-codes/E0027-teach.stderr b/src/test/ui/error-codes/E0027-teach.stderr
deleted file mode 100644
index aa4cb9d4d18..00000000000
--- a/src/test/ui/error-codes/E0027-teach.stderr
+++ /dev/null
@@ -1,11 +0,0 @@
-error[E0027]: pattern does not mention field `name`
-  --> $DIR/E0027-teach.rs:12:9
-   |
-LL |         Dog { age: x } => {}
-   |         ^^^^^^^^^^^^^^ missing field `name`
-   |
-   = note: This error indicates that a pattern for a struct fails to specify a sub-pattern for every one of the struct's fields. Ensure that each field from the struct's definition is mentioned in the pattern, or use `..` to ignore unwanted fields.
-
-error: aborting due to previous error
-
-For more information about this error, try `rustc --explain E0027`.
diff --git a/src/test/ui/error-codes/E0027.rs b/src/test/ui/error-codes/E0027.rs
index b8c6a2b7fcd..8d08e178934 100644
--- a/src/test/ui/error-codes/E0027.rs
+++ b/src/test/ui/error-codes/E0027.rs
@@ -7,7 +7,9 @@ fn main() {
     let d = Dog { name: "Rusty".to_string(), age: 8 };
 
     match d {
-        Dog { age: x } => {}
-        //~^ ERROR pattern does not mention field `name`
+        Dog { age: x } => {} //~ ERROR pattern does not mention field `name`
+    }
+    match d {
+        Dog {} => {} //~ ERROR pattern does not mention fields `name`, `age`
     }
 }
diff --git a/src/test/ui/error-codes/E0027.stderr b/src/test/ui/error-codes/E0027.stderr
index 4f17bba6477..c09f1ff1f2a 100644
--- a/src/test/ui/error-codes/E0027.stderr
+++ b/src/test/ui/error-codes/E0027.stderr
@@ -3,7 +3,31 @@ error[E0027]: pattern does not mention field `name`
    |
 LL |         Dog { age: x } => {}
    |         ^^^^^^^^^^^^^^ missing field `name`
+   |
+help: include the missing field in the pattern
+   |
+LL |         Dog { age: x, name } => {}
+   |                     ^^^^^^
+help: if you don't care about this missing field, you can explicitely ignore it
+   |
+LL |         Dog { age: x, .. } => {}
+   |                     ^^^^
+
+error[E0027]: pattern does not mention fields `name`, `age`
+  --> $DIR/E0027.rs:13:9
+   |
+LL |         Dog {} => {}
+   |         ^^^^^^ missing fields `name`, `age`
+   |
+help: include the missing fields in the pattern
+   |
+LL |         Dog { name, age } => {}
+   |             ^^^^^^^^^^^^^
+help: if you don't care about these missing fields, you can explicitely ignore them
+   |
+LL |         Dog { .. } => {}
+   |             ^^^^^^
 
-error: aborting due to previous error
+error: aborting due to 2 previous errors
 
 For more information about this error, try `rustc --explain E0027`.