diff options
| author | bors <bors@rust-lang.org> | 2016-10-26 21:47:25 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2016-10-26 21:47:25 -0700 |
| commit | bc283c9487b4607d0a97635dca8c8812b886047b (patch) | |
| tree | 040a1ecd30c067e722c03ff8a05dc1de0dfb2c29 /src/libsyntax/ext | |
| parent | 4a584637b0081c96c53c6048fd3715912c94a59b (diff) | |
| parent | 9908711e5e985e322a9576b25f982835504ead5c (diff) | |
| download | rust-bc283c9487b4607d0a97635dca8c8812b886047b.tar.gz rust-bc283c9487b4607d0a97635dca8c8812b886047b.zip | |
Auto merge of #11994 - eddyb:struct-literal-field-shorthand, r=nrc
Implement field shorthands in struct literal expressions.
Implements #37340 in a straight-forward way: `Foo { x, y: f() }` parses as `Foo { x: x, y: f() }`.
Because of the added `is_shorthand` to `ast::Field`, this is `[syntax-breaking]` (cc @Manishearth).
* [x] Mark the fields as being a shorthand (the exact same way we do it in patterns), for pretty-printing.
* [x] Gate the shorthand syntax with `#![feature(field_init_shorthand)]`.
* [x] Don't parse numeric field as identifiers.
* [x] Arbitrary field order tests.
Diffstat (limited to 'src/libsyntax/ext')
| -rw-r--r-- | src/libsyntax/ext/build.rs | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/libsyntax/ext/build.rs b/src/libsyntax/ext/build.rs index bdbc45471bb..0ef47bd6daa 100644 --- a/src/libsyntax/ext/build.rs +++ b/src/libsyntax/ext/build.rs @@ -713,7 +713,7 @@ impl<'a> AstBuilder for ExtCtxt<'a> { self.expr(b.span, ast::ExprKind::Block(b)) } fn field_imm(&self, span: Span, name: Ident, e: P<ast::Expr>) -> ast::Field { - ast::Field { ident: respan(span, name), expr: e, span: span } + ast::Field { ident: respan(span, name), expr: e, span: span, is_shorthand: false } } fn expr_struct(&self, span: Span, path: ast::Path, fields: Vec<ast::Field>) -> P<ast::Expr> { self.expr(span, ast::ExprKind::Struct(path, fields, None)) |
