]> git.lizzy.rs Git - rust.git/commitdiff
Do not complain about unmentioned fields in recovered patterns
authorEsteban Küber <esteban@kuber.com.ar>
Fri, 15 Mar 2019 01:28:24 +0000 (18:28 -0700)
committerEsteban Küber <esteban@kuber.com.ar>
Fri, 15 Mar 2019 01:28:24 +0000 (18:28 -0700)
When the parser has to recover from malformed code in a pattern, do not
complain about missing fields.

src/libsyntax/parse/parser.rs
src/test/ui/parser/bind-struct-early-modifiers.rs
src/test/ui/parser/bind-struct-early-modifiers.stderr
src/test/ui/parser/issue-10392.rs
src/test/ui/parser/issue-10392.stderr
src/test/ui/resolve/issue-54379.rs
src/test/ui/resolve/issue-54379.stderr

index fe31311094b89412624eded504cb630872c0854b..a3894a332230e7291418f57c90a7caa46f9d83ef 100644 (file)
@@ -4698,7 +4698,7 @@ fn parse_pat_with_range_pat(
                         let (fields, etc) = self.parse_pat_fields().unwrap_or_else(|mut e| {
                             e.emit();
                             self.recover_stmt();
-                            (vec![], false)
+                            (vec![], true)
                         });
                         self.bump();
                         pat = PatKind::Struct(path, fields, etc);
index c1de0df54e278112637a2726177ac19279c3f24e..c4b1937de104f491516280e2ec8e857cbbb58474 100644 (file)
@@ -2,7 +2,6 @@ fn main() {
     struct Foo { x: isize }
     match (Foo { x: 10 }) {
         Foo { ref x: ref x } => {}, //~ ERROR expected `,`
-                                    //~| ERROR pattern does not mention field `x`
         _ => {}
     }
 }
index 50c95b8cf4023e59d1eff9f75f288df811807a47..03482a41f546597720f4a2f2348739ec7d4446d3 100644 (file)
@@ -4,12 +4,5 @@ error: expected `,`
 LL |         Foo { ref x: ref x } => {},
    |                   ^
 
-error[E0027]: pattern does not mention field `x`
-  --> $DIR/bind-struct-early-modifiers.rs:4:9
-   |
-LL |         Foo { ref x: ref x } => {},
-   |         ^^^^^^^^^^^^^^^^^^^^ missing field `x`
-
-error: aborting due to 2 previous errors
+error: aborting due to previous error
 
-For more information about this error, try `rustc --explain E0027`.
index dd84af393003ce0d4fe174e090eb6dcdf3cc8238..5b0c2fc2be4076dc38007aaa4fba6cd1406df267 100644 (file)
@@ -4,5 +4,4 @@ fn a() -> A { panic!() }
 
 fn main() {
     let A { , } = a(); //~ ERROR expected ident
-                       //~| ERROR pattern does not mention field `foo`
 }
index 7bf5aa93f0a59be2c861aaedba52ba8b769f680b..34991151c1eb63eafaa9a713eb8b4ea7e08df2f0 100644 (file)
@@ -4,12 +4,5 @@ error: expected identifier, found `,`
 LL |     let A { , } = a();
    |             ^ expected identifier
 
-error[E0027]: pattern does not mention field `foo`
-  --> $DIR/issue-10392.rs:6:9
-   |
-LL |     let A { , } = a();
-   |         ^^^^^^^ missing field `foo`
-
-error: aborting due to 2 previous errors
+error: aborting due to previous error
 
-For more information about this error, try `rustc --explain E0027`.
index a48f66bf0fda0a9f389d326fd433c6da8912fe0a..807c54393f29b55f99a7f6ab1ad141be834bcd66 100644 (file)
@@ -6,7 +6,7 @@ fn main() {
     let thing = MyStruct { s1: None };
 
     match thing {
-        MyStruct { .., Some(_) } => {}, //~ ERROR pattern does not mention field `s1`
+        MyStruct { .., Some(_) } => {},
         //~^ ERROR expected `,`
         //~| ERROR expected `}`, found `,`
         _ => {}
index 60a6f904610b6d310441503c3ba9f3159106c87a..2a6b54572de03eb955bfd7c81d011c1c27f6f510 100644 (file)
@@ -13,12 +13,5 @@ error: expected `,`
 LL |         MyStruct { .., Some(_) } => {},
    |                        ^^^^
 
-error[E0027]: pattern does not mention field `s1`
-  --> $DIR/issue-54379.rs:9:9
-   |
-LL |         MyStruct { .., Some(_) } => {},
-   |         ^^^^^^^^^^^^^^^^^^^^^^^^ missing field `s1`
-
-error: aborting due to 3 previous errors
+error: aborting due to 2 previous errors
 
-For more information about this error, try `rustc --explain E0027`.