From d66d35bb9184b7f3a4e155386ca44410c0d09ff2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Wed, 30 May 2018 11:04:39 -0700 Subject: [PATCH] Account for comma in suggestion --- src/libsyntax/parse/parser.rs | 2 +- src/test/parse-fail/bind-struct-early-modifiers.rs | 2 +- src/test/ui/issue-49257.stderr | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index fb2aa0e9d5afc..d1529347ee0da 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -3868,7 +3868,7 @@ impl<'a> Parser<'a> { "move the `..` to the end of the field list", vec![ (etc_span, "".into()), - (self.span, ", .. }".into()), + (self.span, format!("{}.. }}", if ate_comma { "" } else { ", " })), ], ); } diff --git a/src/test/parse-fail/bind-struct-early-modifiers.rs b/src/test/parse-fail/bind-struct-early-modifiers.rs index 25348a3bfd18f..e9e76af11a530 100644 --- a/src/test/parse-fail/bind-struct-early-modifiers.rs +++ b/src/test/parse-fail/bind-struct-early-modifiers.rs @@ -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 `,` _ => {} } } diff --git a/src/test/ui/issue-49257.stderr b/src/test/ui/issue-49257.stderr index 7c3e7df4a1f32..40179832b49b2 100644 --- a/src/test/ui/issue-49257.stderr +++ b/src/test/ui/issue-49257.stderr @@ -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