Skip to content

Commit bbdef0c

Browse files
committed
rustfmt syntax::parse
1 parent b8b18aa commit bbdef0c

File tree

3 files changed

+49
-49
lines changed

3 files changed

+49
-49
lines changed

src/libsyntax/parse/attr.rs

+34-34
Original file line numberDiff line numberDiff line change
@@ -22,26 +22,25 @@ impl<'a> Parser<'a> {
2222
pub fn parse_outer_attributes(&mut self) -> PResult<'a, Vec<ast::Attribute>> {
2323
let mut attrs: Vec<ast::Attribute> = Vec::new();
2424
loop {
25-
debug!("parse_outer_attributes: self.token={:?}",
26-
self.token);
25+
debug!("parse_outer_attributes: self.token={:?}", self.token);
2726
match self.token {
28-
token::Pound => {
29-
attrs.push(try!(self.parse_attribute(false)));
30-
}
31-
token::DocComment(s) => {
32-
let attr = ::attr::mk_sugared_doc_attr(
27+
token::Pound => {
28+
attrs.push(try!(self.parse_attribute(false)));
29+
}
30+
token::DocComment(s) => {
31+
let attr = ::attr::mk_sugared_doc_attr(
3332
attr::mk_attr_id(),
3433
self.id_to_interned_str(ast::Ident::with_empty_ctxt(s)),
3534
self.span.lo,
3635
self.span.hi
3736
);
38-
if attr.node.style != ast::AttrStyle::Outer {
39-
return Err(self.fatal("expected outer comment"));
37+
if attr.node.style != ast::AttrStyle::Outer {
38+
return Err(self.fatal("expected outer comment"));
39+
}
40+
attrs.push(attr);
41+
self.bump();
4042
}
41-
attrs.push(attr);
42-
self.bump();
43-
}
44-
_ => break
43+
_ => break,
4544
}
4645
}
4746
return Ok(attrs);
@@ -53,24 +52,27 @@ impl<'a> Parser<'a> {
5352
/// attribute
5453
pub fn parse_attribute(&mut self, permit_inner: bool) -> PResult<'a, ast::Attribute> {
5554
debug!("parse_attributes: permit_inner={:?} self.token={:?}",
56-
permit_inner, self.token);
55+
permit_inner,
56+
self.token);
5757
let (span, value, mut style) = match self.token {
5858
token::Pound => {
5959
let lo = self.span.lo;
6060
self.bump();
6161

62-
if permit_inner { self.expected_tokens.push(TokenType::Token(token::Not)); }
62+
if permit_inner {
63+
self.expected_tokens.push(TokenType::Token(token::Not));
64+
}
6365
let style = if self.token == token::Not {
6466
self.bump();
6567
if !permit_inner {
6668
let span = self.span;
67-
self.diagnostic().struct_span_err(span,
68-
"an inner attribute is not permitted in \
69-
this context")
70-
.fileline_help(span,
71-
"place inner attribute at the top of \
72-
the module or block")
73-
.emit()
69+
self.diagnostic()
70+
.struct_span_err(span,
71+
"an inner attribute is not permitted in this context")
72+
.fileline_help(span,
73+
"place inner attribute at the top of the module or \
74+
block")
75+
.emit()
7476
}
7577
ast::AttrStyle::Inner
7678
} else {
@@ -92,8 +94,9 @@ impl<'a> Parser<'a> {
9294

9395
if permit_inner && self.token == token::Semi {
9496
self.bump();
95-
self.span_warn(span, "this inner attribute syntax is deprecated. \
96-
The new syntax is `#![foo]`, with a bang and no semicolon");
97+
self.span_warn(span,
98+
"this inner attribute syntax is deprecated. The new syntax is \
99+
`#![foo]`, with a bang and no semicolon");
97100
style = ast::AttrStyle::Inner;
98101
}
99102

@@ -103,8 +106,8 @@ impl<'a> Parser<'a> {
103106
id: attr::mk_attr_id(),
104107
style: style,
105108
value: value,
106-
is_sugared_doc: false
107-
}
109+
is_sugared_doc: false,
110+
},
108111
})
109112
}
110113

@@ -139,7 +142,7 @@ impl<'a> Parser<'a> {
139142
break;
140143
}
141144
}
142-
_ => break
145+
_ => break,
143146
}
144147
}
145148
Ok(attrs)
@@ -150,10 +153,8 @@ impl<'a> Parser<'a> {
150153
/// | IDENT meta_seq
151154
pub fn parse_meta_item(&mut self) -> PResult<'a, P<ast::MetaItem>> {
152155
let nt_meta = match self.token {
153-
token::Interpolated(token::NtMeta(ref e)) => {
154-
Some(e.clone())
155-
}
156-
_ => None
156+
token::Interpolated(token::NtMeta(ref e)) => Some(e.clone()),
157+
_ => None,
157158
};
158159

159160
match nt_meta {
@@ -176,9 +177,8 @@ impl<'a> Parser<'a> {
176177
match lit.node {
177178
ast::LitStr(..) => {}
178179
_ => {
179-
self.span_err(
180-
lit.span,
181-
"non-string literals are not allowed in meta-items");
180+
self.span_err(lit.span,
181+
"non-string literals are not allowed in meta-items");
182182
}
183183
}
184184
let hi = self.span.hi;

src/libsyntax/parse/classify.rs

+14-14
Original file line numberDiff line numberDiff line change
@@ -23,22 +23,22 @@ use ast;
2323
/// isn't parsed as (if true {...} else {...} | x) | 5
2424
pub fn expr_requires_semi_to_be_stmt(e: &ast::Expr) -> bool {
2525
match e.node {
26-
ast::ExprIf(..)
27-
| ast::ExprIfLet(..)
28-
| ast::ExprMatch(..)
29-
| ast::ExprBlock(_)
30-
| ast::ExprWhile(..)
31-
| ast::ExprWhileLet(..)
32-
| ast::ExprLoop(..)
33-
| ast::ExprForLoop(..) => false,
34-
_ => true
26+
ast::ExprIf(..) |
27+
ast::ExprIfLet(..) |
28+
ast::ExprMatch(..) |
29+
ast::ExprBlock(_) |
30+
ast::ExprWhile(..) |
31+
ast::ExprWhileLet(..) |
32+
ast::ExprLoop(..) |
33+
ast::ExprForLoop(..) => false,
34+
_ => true,
3535
}
3636
}
3737

3838
pub fn expr_is_simple_block(e: &ast::Expr) -> bool {
3939
match e.node {
4040
ast::ExprBlock(ref block) => block.rules == ast::DefaultBlock,
41-
_ => false
41+
_ => false,
4242
}
4343
}
4444

@@ -50,11 +50,11 @@ pub fn stmt_ends_with_semi(stmt: &ast::Stmt_) -> bool {
5050
ast::StmtDecl(ref d, _) => {
5151
match d.node {
5252
ast::DeclLocal(_) => true,
53-
ast::DeclItem(_) => false
53+
ast::DeclItem(_) => false,
5454
}
5555
}
56-
ast::StmtExpr(ref e, _) => { expr_requires_semi_to_be_stmt(e) }
57-
ast::StmtSemi(..) => { false }
58-
ast::StmtMac(..) => { false }
56+
ast::StmtExpr(ref e, _) => expr_requires_semi_to_be_stmt(e),
57+
ast::StmtSemi(..) => false,
58+
ast::StmtMac(..) => false,
5959
}
6060
}

src/libsyntax/parse/common.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use parse::token;
1616
/// and whether a trailing separator is allowed.
1717
pub struct SeqSep {
1818
pub sep: Option<token::Token>,
19-
pub trailing_sep_allowed: bool
19+
pub trailing_sep_allowed: bool,
2020
}
2121

2222
pub fn seq_sep_trailing_allowed(t: token::Token) -> SeqSep {

0 commit comments

Comments
 (0)