diff options
| author | Mazdak Farrokhzad <twingoow@gmail.com> | 2019-03-22 19:31:24 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-03-22 19:31:24 +0100 |
| commit | 5a0e4510a805aa7feb93f7a34000be7d5d9a6249 (patch) | |
| tree | df4aff066dccc48f8c83eb25920296a15a8c491e /src/test/ui/parser | |
| parent | adbfcea58f89dee842519d4ef0cbaefe09fac3a5 (diff) | |
| parent | 757eb679927e2c85457f567487e887eb080eb7cb (diff) | |
| download | rust-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.rs | 13 | ||||
| -rw-r--r-- | src/test/ui/parser/recovered-struct-variant.stderr | 8 |
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 + |
