From 4de3c97b2afea55834cd16368f950133459d8c73 Mon Sep 17 00:00:00 2001 From: Christopher Durham Date: Sat, 27 Jan 2018 18:31:23 -0500 Subject: Enforce rustfmt format --- src/parser/event_parser/grammar/attributes.rs | 15 ++++------ src/parser/event_parser/grammar/expressions.rs | 8 ++---- src/parser/event_parser/grammar/items.rs | 38 ++++++++------------------ src/parser/event_parser/grammar/mod.rs | 25 +++++++---------- src/parser/event_parser/grammar/paths.rs | 4 +-- src/parser/event_parser/grammar/types.rs | 2 +- 6 files changed, 31 insertions(+), 61 deletions(-) (limited to 'src/parser/event_parser/grammar') diff --git a/src/parser/event_parser/grammar/attributes.rs b/src/parser/event_parser/grammar/attributes.rs index 045840059..8bf04afce 100644 --- a/src/parser/event_parser/grammar/attributes.rs +++ b/src/parser/event_parser/grammar/attributes.rs @@ -12,8 +12,7 @@ pub(super) fn outer_attributes(p: &mut Parser) { } } - -fn attribute(p: &mut Parser, inner: bool){ +fn attribute(p: &mut Parser, inner: bool) { let attr = p.start(); assert!(p.at(POUND)); p.bump(); @@ -38,9 +37,7 @@ fn meta_item(p: &mut Parser) { EQ => { p.bump(); if !expressions::literal(p) { - p.error() - .message("expected literal") - .emit(); + p.error().message("expected literal").emit(); } } L_PAREN => meta_item_arg_list(p), @@ -48,9 +45,7 @@ fn meta_item(p: &mut Parser) { } meta_item.complete(p, META_ITEM); } else { - p.error() - .message("expected attribute value") - .emit() + p.error().message("expected attribute value").emit() } } @@ -73,8 +68,8 @@ fn meta_item_arg_list(p: &mut Parser) { p.error().message(message).emit(); p.bump(); err.complete(p, ERROR); - continue - } + continue; + }, } if !p.at(R_PAREN) { p.expect(COMMA); diff --git a/src/parser/event_parser/grammar/expressions.rs b/src/parser/event_parser/grammar/expressions.rs index a943b8c81..c81dc6c35 100644 --- a/src/parser/event_parser/grammar/expressions.rs +++ b/src/parser/event_parser/grammar/expressions.rs @@ -2,15 +2,13 @@ use super::*; pub(super) fn literal(p: &mut Parser) -> bool { match p.current() { - TRUE_KW | FALSE_KW | - INT_NUMBER | FLOAT_NUMBER | - BYTE | CHAR | - STRING | RAW_STRING | BYTE_STRING | RAW_BYTE_STRING => { + TRUE_KW | FALSE_KW | INT_NUMBER | FLOAT_NUMBER | BYTE | CHAR | STRING | RAW_STRING + | BYTE_STRING | RAW_BYTE_STRING => { let lit = p.start(); p.bump(); lit.complete(p, LITERAL); true } - _ => false + _ => false, } } diff --git a/src/parser/event_parser/grammar/items.rs b/src/parser/event_parser/grammar/items.rs index 7706690cc..e569e5047 100644 --- a/src/parser/event_parser/grammar/items.rs +++ b/src/parser/event_parser/grammar/items.rs @@ -7,15 +7,8 @@ pub(super) fn mod_contents(p: &mut Parser) { } } -pub(super) const ITEM_FIRST: TokenSet = token_set![ - EXTERN_KW, - MOD_KW, - USE_KW, - STRUCT_KW, - FN_KW, - PUB_KW, - POUND, -]; +pub(super) const ITEM_FIRST: TokenSet = + token_set![EXTERN_KW, MOD_KW, USE_KW, STRUCT_KW, FN_KW, PUB_KW, POUND,]; fn item(p: &mut Parser) { let item = p.start(); @@ -48,7 +41,7 @@ fn item(p: &mut Parser) { let message = if err_token == SEMI { //TODO: if the item is incomplete, this message is misleading "expected item, found `;`\n\ - consider removing this semicolon" + consider removing this semicolon" } else { "expected item" }; @@ -76,10 +69,9 @@ fn struct_item(p: &mut Parser) { return; } L_CURLY => named_fields(p), - _ => { //TODO: special case `(` error message - p.error() - .message("expected `;` or `{`") - .emit(); + _ => { + //TODO: special case `(` error message + p.error().message("expected `;` or `{`").emit(); return; } } @@ -94,9 +86,7 @@ fn struct_item(p: &mut Parser) { p.expect(SEMI); } _ => { - p.error() - .message("expected `;`, `{`, or `(`") - .emit(); + p.error().message("expected `;`, `{`, or `(`").emit(); return; } } @@ -177,7 +167,7 @@ fn use_item(p: &mut Parser) { use_tree(p); p.expect(SEMI); - fn use_tree(p: &mut Parser){ + fn use_tree(p: &mut Parser) { let la = p.raw_lookahead(1); let m = p.start(); match (p.current(), la) { @@ -209,9 +199,7 @@ fn use_item(p: &mut Parser) { L_CURLY => nested_trees(p), _ => { // is this unreachable? - p.error() - .message("expected `{` or `*`") - .emit(); + p.error().message("expected `{` or `*`").emit(); } } } @@ -222,7 +210,7 @@ fn use_item(p: &mut Parser) { m.abandon(p); p.err_and_bump("expected one of `*`, `::`, `{`, `self`, `super`, `indent`"); return; - }, + } } m.complete(p, USE_TREE); } @@ -240,13 +228,9 @@ fn use_item(p: &mut Parser) { } } - fn fn_item(p: &mut Parser) { assert!(p.at(FN_KW)); p.bump(); - p.expect(IDENT) && p.expect(L_PAREN) && p.expect(R_PAREN) - && p.curly_block(|_| ()); + p.expect(IDENT) && p.expect(L_PAREN) && p.expect(R_PAREN) && p.curly_block(|_| ()); } - - diff --git a/src/parser/event_parser/grammar/mod.rs b/src/parser/event_parser/grammar/mod.rs index 6e4f72096..c6ab1fbe2 100644 --- a/src/parser/event_parser/grammar/mod.rs +++ b/src/parser/event_parser/grammar/mod.rs @@ -1,5 +1,5 @@ use super::parser::{Parser, TokenSet}; -use {SyntaxKind}; +use SyntaxKind; use tree::EOF; use syntax_kinds::*; @@ -29,7 +29,7 @@ fn visibility(p: &mut Parser) { } p.expect(R_PAREN); } - _ => () + _ => (), } } vis.complete(p, VISIBILITY); @@ -53,9 +53,7 @@ impl<'p> Parser<'p> { fn err_and_bump(&mut self, message: &str) { let err = self.start(); - self.error() - .message(message) - .emit(); + self.error().message(message).emit(); self.bump(); err.complete(self, ERROR); } @@ -65,15 +63,16 @@ impl<'p> Parser<'p> { self.bump(); true } else { - self.error() - .message(format!("expected {:?}", kind)) - .emit(); + self.error().message(format!("expected {:?}", kind)).emit(); false } } fn eat(&mut self, kind: SyntaxKind) -> bool { - self.current() == kind && { self.bump(); true } + self.current() == kind && { + self.bump(); + true + } } } @@ -94,8 +93,7 @@ impl Lookahead for SyntaxKind { impl Lookahead for [SyntaxKind; 2] { fn is_ahead(self, p: &Parser) -> bool { - p.current() == self[0] - && p.raw_lookahead(1) == self[1] + p.current() == self[0] && p.raw_lookahead(1) == self[1] } fn consume(p: &mut Parser) { @@ -106,9 +104,7 @@ impl Lookahead for [SyntaxKind; 2] { impl Lookahead for [SyntaxKind; 3] { fn is_ahead(self, p: &Parser) -> bool { - p.current() == self[0] - && p.raw_lookahead(1) == self[1] - && p.raw_lookahead(2) == self[2] + p.current() == self[0] && p.raw_lookahead(1) == self[1] && p.raw_lookahead(2) == self[2] } fn consume(p: &mut Parser) { @@ -130,5 +126,4 @@ impl<'a> Lookahead for AnyOf<'a> { fn consume(p: &mut Parser) { p.bump(); } - } diff --git a/src/parser/event_parser/grammar/paths.rs b/src/parser/event_parser/grammar/paths.rs index b58c59aef..4e028073a 100644 --- a/src/parser/event_parser/grammar/paths.rs +++ b/src/parser/event_parser/grammar/paths.rs @@ -34,9 +34,7 @@ fn path_segment(p: &mut Parser, first: bool) { p.bump(); } _ => { - p.error() - .message("expected identifier") - .emit(); + p.error().message("expected identifier").emit(); } }; segment.complete(p, PATH_SEGMENT); diff --git a/src/parser/event_parser/grammar/types.rs b/src/parser/event_parser/grammar/types.rs index c431643d7..1a3d44a0a 100644 --- a/src/parser/event_parser/grammar/types.rs +++ b/src/parser/event_parser/grammar/types.rs @@ -2,4 +2,4 @@ use super::*; pub(super) fn type_ref(p: &mut Parser) { p.expect(IDENT); -} \ No newline at end of file +} -- cgit v1.2.3