]> git.lizzy.rs Git - rust.git/commitdiff
Account for comma in suggestion
authorEsteban Küber <esteban@kuber.com.ar>
Wed, 30 May 2018 18:04:39 +0000 (11:04 -0700)
committerEsteban Küber <esteban@kuber.com.ar>
Tue, 5 Jun 2018 15:48:55 +0000 (08:48 -0700)
src/libsyntax/parse/parser.rs
src/test/parse-fail/bind-struct-early-modifiers.rs
src/test/ui/issue-49257.stderr

index fb2aa0e9d5afc84c460757d312252d8a01c3c13f..d1529347ee0da1963fe8b61faf72aa55291d7622 100644 (file)
@@ -3868,7 +3868,7 @@ fn parse_pat_fields(&mut self) -> PResult<'a, (Vec<codemap::Spanned<ast::FieldPa
                     "move the `..` to the end of the field list",
                     vec![
                         (etc_span, "".into()),
-                        (self.span, ", .. }".into()),
+                        (self.span, format!("{}.. }}", if ate_comma { "" } else { ", " })),
                     ],
                 );
             }
index 25348a3bfd18fc864dd79adfb4f7b19cc87d14a3..e9e76af11a530a7c26056fe0205cbae229868aea 100644 (file)
@@ -13,7 +13,7 @@
 fn main() {
     struct Foo { x: isize }
     match (Foo { x: 10 }) {
-        Foo { ref x: ref x } => {}, //~ ERROR expected `,`, found `:`
+        Foo { ref x: ref x } => {}, //~ ERROR expected `,`
         _ => {}
     }
 }
index 7c3e7df4a1f327eeea3926a9300d8ec919d29424..40179832b49b271bee71a2151c2ec9ecc1a6775a 100644 (file)
@@ -8,8 +8,8 @@ LL |     let Point { .., y, } = p; //~ ERROR expected `}`, found `,`
    |                 `..` must be at the end and cannot have a trailing comma
 help: move the `..` to the end of the field list
    |
-LL |     let Point {  y, .. } = p; //~ ERROR expected `}`, found `,`
-   |                --   ^^^^^^
+LL |     let Point {  y, .. } = p; //~ ERROR expected `}`, found `,`
+   |                --   ^^^^
 
 error: expected `}`, found `,`
   --> $DIR/issue-49257.rs:21:19