about summary refs log tree commit diff
path: root/src/test/ui/parser
diff options
context:
space:
mode:
authorMazdak Farrokhzad <twingoow@gmail.com>2019-03-22 19:31:24 +0100
committerGitHub <noreply@github.com>2019-03-22 19:31:24 +0100
commit5a0e4510a805aa7feb93f7a34000be7d5d9a6249 (patch)
treedf4aff066dccc48f8c83eb25920296a15a8c491e /src/test/ui/parser
parentadbfcea58f89dee842519d4ef0cbaefe09fac3a5 (diff)
parent757eb679927e2c85457f567487e887eb080eb7cb (diff)
downloadrust-5a0e4510a805aa7feb93f7a34000be7d5d9a6249.tar.gz
rust-5a0e4510a805aa7feb93f7a34000be7d5d9a6249.zip
Rollup merge of #59266 - estebank:struct-parse-recovery, r=petrochenkov
Do not complain about non-existing fields after parse recovery

When failing to parse struct-like enum variants, the ADT gets recorded
as having no fields. Record that we have actually recovered during
parsing of this variant to avoid complaing about non-existing fields
when actually using it.

Fix #57361.
Diffstat (limited to 'src/test/ui/parser')
-rw-r--r--src/test/ui/parser/recovered-struct-variant.rs13
-rw-r--r--src/test/ui/parser/recovered-struct-variant.stderr8
2 files changed, 21 insertions, 0 deletions
diff --git a/src/test/ui/parser/recovered-struct-variant.rs b/src/test/ui/parser/recovered-struct-variant.rs
new file mode 100644
index 00000000000..5b195dcc378
--- /dev/null
+++ b/src/test/ui/parser/recovered-struct-variant.rs
@@ -0,0 +1,13 @@
+enum Foo {
+    A { a, b: usize }
+    //~^ ERROR expected `:`, found `,`
+}
+
+fn main() {
+    // no complaints about non-existing fields
+    let f = Foo::A { a:3, b: 4};
+    match f {
+        // no complaints about non-existing fields
+        Foo::A {a, b} => {}
+    }
+}
diff --git a/src/test/ui/parser/recovered-struct-variant.stderr b/src/test/ui/parser/recovered-struct-variant.stderr
new file mode 100644
index 00000000000..51aaf8bb3cf
--- /dev/null
+++ b/src/test/ui/parser/recovered-struct-variant.stderr
@@ -0,0 +1,8 @@
+error: expected `:`, found `,`
+  --> $DIR/recovered-struct-variant.rs:2:10
+   |
+LL |     A { a, b: usize }
+   |          ^ expected `:`
+
+error: aborting due to previous error
+