diff options
| author | Zack M. Davis <code@zackmdavis.net> | 2017-08-06 22:54:09 -0700 |
|---|---|---|
| committer | Zack M. Davis <code@zackmdavis.net> | 2017-08-15 15:29:17 -0700 |
| commit | 1b6c9605e41b7c7dc23e0e6f633f05912d0463dd (patch) | |
| tree | 2482313e8e0761fd8e3ecddc8baad7bf96689b07 /src/libsyntax/parse | |
| parent | 82be83cf744611a016fb09ae1afbffc04b3ed2e1 (diff) | |
| download | rust-1b6c9605e41b7c7dc23e0e6f633f05912d0463dd.tar.gz rust-1b6c9605e41b7c7dc23e0e6f633f05912d0463dd.zip | |
use field init shorthand EVERYWHERE
Like #43008 (f668999), but _much more aggressive_.
Diffstat (limited to 'src/libsyntax/parse')
| -rw-r--r-- | src/libsyntax/parse/attr.rs | 8 | ||||
| -rw-r--r-- | src/libsyntax/parse/lexer/comments.rs | 6 | ||||
| -rw-r--r-- | src/libsyntax/parse/lexer/mod.rs | 10 | ||||
| -rw-r--r-- | src/libsyntax/parse/lexer/tokentrees.rs | 2 | ||||
| -rw-r--r-- | src/libsyntax/parse/mod.rs | 2 | ||||
| -rw-r--r-- | src/libsyntax/parse/parser.rs | 168 |
6 files changed, 98 insertions, 98 deletions
diff --git a/src/libsyntax/parse/attr.rs b/src/libsyntax/parse/attr.rs index c99a09ab24e..5dc5a53e279 100644 --- a/src/libsyntax/parse/attr.rs +++ b/src/libsyntax/parse/attr.rs @@ -141,11 +141,11 @@ impl<'a> Parser<'a> { Ok(ast::Attribute { id: attr::mk_attr_id(), - style: style, - path: path, - tokens: tokens, + style, + path, + tokens, is_sugared_doc: false, - span: span, + span, }) } diff --git a/src/libsyntax/parse/lexer/comments.rs b/src/libsyntax/parse/lexer/comments.rs index 8b545d3b909..f65fffebe33 100644 --- a/src/libsyntax/parse/lexer/comments.rs +++ b/src/libsyntax/parse/lexer/comments.rs @@ -192,7 +192,7 @@ fn read_line_comments(rdr: &mut StringReader, if !lines.is_empty() { comments.push(Comment { style: if code_to_the_left { Trailing } else { Isolated }, - lines: lines, + lines, pos: p, }); } @@ -306,8 +306,8 @@ fn read_block_comment(rdr: &mut StringReader, } debug!("<<< block comment"); comments.push(Comment { - style: style, - lines: lines, + style, + lines, pos: p, }); } diff --git a/src/libsyntax/parse/lexer/mod.rs b/src/libsyntax/parse/lexer/mod.rs index 09cdf26bf1f..527d2e41396 100644 --- a/src/libsyntax/parse/lexer/mod.rs +++ b/src/libsyntax/parse/lexer/mod.rs @@ -160,18 +160,18 @@ impl<'a> StringReader<'a> { let source_text = (*filemap.src.as_ref().unwrap()).clone(); StringReader { - sess: sess, + sess, next_pos: filemap.start_pos, pos: filemap.start_pos, col: CharPos(0), ch: Some('\n'), - filemap: filemap, + filemap, terminator: None, save_new_lines_and_multibyte: true, // dummy values; not read peek_tok: token::Eof, peek_span: syntax_pos::DUMMY_SP, - source_text: source_text, + source_text, fatal_errs: Vec::new(), token: token::Eof, span: syntax_pos::DUMMY_SP, @@ -546,7 +546,7 @@ impl<'a> StringReader<'a> { }; Some(TokenAndSpan { - tok: tok, + tok, sp: self.mk_sp(start_bpos, self.pos), }) }) @@ -675,7 +675,7 @@ impl<'a> StringReader<'a> { }; Some(TokenAndSpan { - tok: tok, + tok, sp: self.mk_sp(start_bpos, self.pos), }) }) diff --git a/src/libsyntax/parse/lexer/tokentrees.rs b/src/libsyntax/parse/lexer/tokentrees.rs index 63a396c14db..ad389ab510a 100644 --- a/src/libsyntax/parse/lexer/tokentrees.rs +++ b/src/libsyntax/parse/lexer/tokentrees.rs @@ -114,7 +114,7 @@ impl<'a> StringReader<'a> { } Ok(TokenTree::Delimited(span, Delimited { - delim: delim, + delim, tts: tts.into(), })) }, diff --git a/src/libsyntax/parse/mod.rs b/src/libsyntax/parse/mod.rs index 957164bab79..67b4954a8f1 100644 --- a/src/libsyntax/parse/mod.rs +++ b/src/libsyntax/parse/mod.rs @@ -69,7 +69,7 @@ impl ParseSess { config: HashSet::new(), missing_fragment_specifiers: RefCell::new(HashSet::new()), included_mod_stack: RefCell::new(vec![]), - code_map: code_map + code_map, } } diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 15f05df58b5..e251d136f23 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -465,17 +465,17 @@ impl From<P<Expr>> for LhsExpr { /// Create a placeholder argument. fn dummy_arg(span: Span) -> Arg { let spanned = Spanned { - span: span, + span, node: keywords::Invalid.ident() }; let pat = P(Pat { id: ast::DUMMY_NODE_ID, node: PatKind::Ident(BindingMode::ByValue(Mutability::Immutable), spanned, None), - span: span + span, }); let ty = Ty { node: TyKind::Err, - span: span, + span, id: ast::DUMMY_NODE_ID }; Arg { ty: P(ty), pat: pat, id: ast::DUMMY_NODE_ID } @@ -489,7 +489,7 @@ impl<'a> Parser<'a> { desugar_doc_comments: bool) -> Self { let mut parser = Parser { - sess: sess, + sess, token: token::Underscore, span: syntax_pos::DUMMY_SP, prev_span: syntax_pos::DUMMY_SP, @@ -497,7 +497,7 @@ impl<'a> Parser<'a> { prev_token_kind: PrevTokenKind::Other, restrictions: Restrictions::empty(), obsolete_set: HashSet::new(), - recurse_into_file_modules: recurse_into_file_modules, + recurse_into_file_modules, directory: Directory { path: PathBuf::new(), ownership: DirectoryOwnership::Owned }, root_module_name: None, expected_tokens: Vec::new(), @@ -508,7 +508,7 @@ impl<'a> Parser<'a> { }), stack: Vec::new(), }, - desugar_doc_comments: desugar_doc_comments, + desugar_doc_comments, cfg_mods: true, }; @@ -1216,15 +1216,15 @@ impl<'a> Parser<'a> { let (inputs, variadic) = self.parse_fn_args(false, true)?; let ret_ty = self.parse_ret_ty()?; let decl = P(FnDecl { - inputs: inputs, + inputs, output: ret_ty, - variadic: variadic + variadic, }); Ok(TyKind::BareFn(P(BareFnTy { - abi: abi, - unsafety: unsafety, + abi, + unsafety, lifetimes: lifetime_defs, - decl: decl + decl, }))) } @@ -1312,11 +1312,11 @@ impl<'a> Parser<'a> { generics.where_clause = self.parse_where_clause()?; let sig = ast::MethodSig { - unsafety: unsafety, - constness: constness, + unsafety, + constness, decl: d, - generics: generics, - abi: abi, + generics, + abi, }; let body = match self.token { @@ -1344,8 +1344,8 @@ impl<'a> Parser<'a> { Ok(TraitItem { id: ast::DUMMY_NODE_ID, ident: name, - attrs: attrs, - node: node, + attrs, + node, span: lo.to(self.prev_span), tokens: None, }) @@ -1625,7 +1625,7 @@ impl<'a> Parser<'a> { Ok(Arg { ty: t, - pat: pat, + pat, id: ast::DUMMY_NODE_ID, }) } @@ -1649,7 +1649,7 @@ impl<'a> Parser<'a> { }; Ok(Arg { ty: t, - pat: pat, + pat, id: ast::DUMMY_NODE_ID }) } @@ -1934,8 +1934,8 @@ impl<'a> Parser<'a> { Ok(ast::Field { ident: respan(lo.to(hi), fieldname), span: lo.to(expr.span), - expr: expr, - is_shorthand: is_shorthand, + expr, + is_shorthand, attrs: attrs.into(), }) } @@ -1943,8 +1943,8 @@ impl<'a> Parser<'a> { pub fn mk_expr(&mut self, span: Span, node: ExprKind, attrs: ThinVec<Attribute>) -> P<Expr> { P(Expr { id: ast::DUMMY_NODE_ID, - node: node, - span: span, + node, + span, attrs: attrs.into(), }) } @@ -1990,8 +1990,8 @@ impl<'a> Parser<'a> { P(Expr { id: ast::DUMMY_NODE_ID, node: ExprKind::Mac(codemap::Spanned {node: m, span: span}), - span: span, - attrs: attrs, + span, + attrs, }) } @@ -2006,7 +2006,7 @@ impl<'a> Parser<'a> { id: ast::DUMMY_NODE_ID, node: ExprKind::Lit(lv_lit), span: *span, - attrs: attrs, + attrs, }) } @@ -3153,9 +3153,9 @@ impl<'a> Parser<'a> { } Ok(ast::Arm { - attrs: attrs, - pats: pats, - guard: guard, + attrs, + pats, + guard, body: expr, }) } @@ -3361,7 +3361,7 @@ impl<'a> Parser<'a> { node: ast::FieldPat { ident: fieldname, pat: subpat, - is_shorthand: is_shorthand, + is_shorthand, attrs: attrs.into(), } }); @@ -3597,12 +3597,12 @@ impl<'a> Parser<'a> { }; let init = self.parse_initializer()?; Ok(P(ast::Local { - ty: ty, - pat: pat, - init: init, + ty, + pat, + init, id: ast::DUMMY_NODE_ID, span: lo.to(self.prev_span), - attrs: attrs, + attrs, })) } @@ -3618,10 +3618,10 @@ impl<'a> Parser<'a> { Ok(StructField { span: lo.to(self.prev_span), ident: Some(name), - vis: vis, + vis, id: ast::DUMMY_NODE_ID, - ty: ty, - attrs: attrs, + ty, + attrs, }) } @@ -3929,7 +3929,7 @@ impl<'a> Parser<'a> { Stmt { id: ast::DUMMY_NODE_ID, span: lo.to(hi), - node: node, + node, } } else { // if it has a special ident, it's definitely an item @@ -3946,7 +3946,7 @@ impl<'a> Parser<'a> { let span = lo.to(hi); Stmt { id: ast::DUMMY_NODE_ID, - span: span, + span, node: StmtKind::Item({ self.mk_item( span, id /*id is good here*/, @@ -4083,7 +4083,7 @@ impl<'a> Parser<'a> { } Ok(P(ast::Block { - stmts: stmts, + stmts, id: ast::DUMMY_NODE_ID, rules: s, span: lo.to(self.prev_span), @@ -4227,11 +4227,11 @@ impl<'a> Parser<'a> { Ok(TyParam { attrs: preceding_attrs.into(), - ident: ident, + ident, id: ast::DUMMY_NODE_ID, - bounds: bounds, - default: default, - span: span, + bounds, + default, + span, }) } @@ -4253,8 +4253,8 @@ impl<'a> Parser<'a> { }; lifetime_defs.push(LifetimeDef { attrs: attrs.into(), - lifetime: lifetime, - bounds: bounds, + lifetime, + bounds, }); if seen_ty_param { self.span_err(self.prev_span, @@ -4297,7 +4297,7 @@ impl<'a> Parser<'a> { self.expect_gt()?; Ok(ast::Generics { lifetimes: lifetime_defs, - ty_params: ty_params, + ty_params, where_clause: WhereClause { id: ast::DUMMY_NODE_ID, predicates: Vec::new(), @@ -4334,8 +4334,8 @@ impl<'a> Parser<'a> { let ty = self.parse_ty()?; bindings.push(TypeBinding { id: ast::DUMMY_NODE_ID, - ident: ident, - ty: ty, + ident, + ty, span: lo.to(self.prev_span), }); seen_binding = true; @@ -4404,8 +4404,8 @@ impl<'a> Parser<'a> { where_clause.predicates.push(ast::WherePredicate::RegionPredicate( ast::WhereRegionPredicate { span: lo.to(self.prev_span), - lifetime: lifetime, - bounds: bounds, + lifetime, + bounds, } )); } else if self.check_type() { @@ -4427,7 +4427,7 @@ impl<'a> Parser<'a> { span: lo.to(self.prev_span), bound_lifetimes: lifetime_defs, bounded_ty: ty, - bounds: bounds, + bounds, } )); // FIXME: Decide what should be used here, `=` or `==`. @@ -4437,7 +4437,7 @@ impl<'a> Parser<'a> { ast::WhereEqPredicate { span: lo.to(self.prev_span), lhs_ty: ty, - rhs_ty: rhs_ty, + rhs_ty, id: ast::DUMMY_NODE_ID, } )); @@ -4518,7 +4518,7 @@ impl<'a> Parser<'a> { Ok(P(FnDecl { inputs: args, output: ret_ty, - variadic: variadic + variadic, })) } @@ -4679,7 +4679,7 @@ impl<'a> Parser<'a> { Ok(P(FnDecl { inputs: inputs_captures, - output: output, + output, variadic: false })) } @@ -4694,12 +4694,12 @@ impl<'a> Parser<'a> { fn mk_item(&mut self, span: Span, ident: Ident, node: ItemKind, vis: Visibility, attrs: Vec<Attribute>) -> P<Item> { P(Item { - ident: ident, - attrs: attrs, + ident, + attrs, id: ast::DUMMY_NODE_ID, - node: node, - vis: vis, - span: span, + node, + vis, + span, tokens: None, }) } @@ -4799,10 +4799,10 @@ impl<'a> Parser<'a> { id: ast::DUMMY_NODE_ID, span: lo.to(self.prev_span), ident: name, - vis: vis, - defaultness: defaultness, - attrs: attrs, - node: node, + vis, + defaultness, + attrs, + node, tokens: None, }) } @@ -4896,11 +4896,11 @@ impl<'a> Parser<'a> { *at_end = true; let (inner_attrs, body) = self.parse_inner_attrs_and_block()?; Ok((ident, inner_attrs, ast::ImplItemKind::Method(ast::MethodSig { - generics: generics, - abi: abi, - unsafety: unsafety, - constness: constness, - decl: decl + generics, + abi, + unsafety, + constness, + decl, }, body))) } } @@ -5151,11 +5151,11 @@ impl<'a> Parser<'a> { let ty = p.parse_ty()?; Ok(StructField { span: lo.to(p.span), - vis: vis, + vis, ident: None, id: ast::DUMMY_NODE_ID, - ty: ty, - attrs: attrs, + ty, + attrs, }) })?; @@ -5281,7 +5281,7 @@ impl<'a> Parser<'a> { Ok(ast::Mod { inner: inner_lo.to(hi), - items: items + items, }) } @@ -5403,7 +5403,7 @@ impl<'a> Parser<'a> { ModulePath { name: mod_name, path_exists: default_exists || secondary_exists, - result: result, + result, } } @@ -5418,7 +5418,7 @@ impl<'a> Parser<'a> { Some("mod.rs") => DirectoryOwnership::Owned, _ => DirectoryOwnership::UnownedViaMod(true), }, - path: path, + path, warn: false, }); } @@ -5509,12 +5509,12 @@ impl<'a> Parser<'a> { let hi = self.span; self.expect(&token::Semi)?; Ok(ast::ForeignItem { - ident: ident, - attrs: attrs, + ident, + attrs, node: ForeignItemKind::Fn(decl, generics), id: ast::DUMMY_NODE_ID, span: lo.to(hi), - vis: vis + vis, }) } @@ -5529,12 +5529,12 @@ impl<'a> Parser<'a> { let hi = self.span; self.expect(&token::Semi)?; Ok(ForeignItem { - ident: ident, - attrs: attrs, + ident, + attrs, node: ForeignItemKind::Static(ty, mutbl), id: ast::DUMMY_NODE_ID, span: lo.to(hi), - vis: vis + vis, }) } @@ -5596,7 +5596,7 @@ impl<'a> Parser<'a> { let prev_span = self.prev_span; let m = ast::ForeignMod { - abi: abi, + abi, items: foreign_items }; let invalid = keywords::Invalid.ident(); @@ -5647,7 +5647,7 @@ impl<'a> Parser<'a> { name: ident, attrs: variant_attrs, data: struct_def, - disr_expr: disr_expr, + disr_expr, }; variants.push(respan(vlo.to(self.prev_span), vr)); @@ -6162,7 +6162,7 @@ impl<'a> Parser<'a> { let rename = this.parse_rename()?; let node = ast::PathListItem_ { name: ident, - rename: rename, + rename, id: ast::DUMMY_NODE_ID }; Ok(respan(lo.to(this.prev_span), node)) |
