Skip to content

Commit 74549f8

Browse files
author
Jonathan Turner
authored
Rollup merge of rust-lang#35614 - srinivasreddy:syntax_ext_rustfmt, r=nikomatsakis
run rustfmt on libsyntax_ext folder
2 parents 559bfd6 + d652639 commit 74549f8

File tree

11 files changed

+273
-247
lines changed

11 files changed

+273
-247
lines changed

src/libsyntax_ext/asm.rs

+38-40
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,8 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
/*
12-
* Inline assembly support.
13-
*/
11+
// Inline assembly support.
12+
//
1413
use self::State::*;
1514

1615
use syntax::ast;
@@ -31,43 +30,48 @@ enum State {
3130
Inputs,
3231
Clobbers,
3332
Options,
34-
StateNone
33+
StateNone,
3534
}
3635

3736
impl State {
3837
fn next(&self) -> State {
3938
match *self {
40-
Asm => Outputs,
41-
Outputs => Inputs,
42-
Inputs => Clobbers,
43-
Clobbers => Options,
44-
Options => StateNone,
45-
StateNone => StateNone
39+
Asm => Outputs,
40+
Outputs => Inputs,
41+
Inputs => Clobbers,
42+
Clobbers => Options,
43+
Options => StateNone,
44+
StateNone => StateNone,
4645
}
4746
}
4847
}
4948

5049
const OPTIONS: &'static [&'static str] = &["volatile", "alignstack", "intel"];
5150

52-
pub fn expand_asm<'cx>(cx: &'cx mut ExtCtxt, sp: Span, tts: &[tokenstream::TokenTree])
53-
-> Box<base::MacResult+'cx> {
51+
pub fn expand_asm<'cx>(cx: &'cx mut ExtCtxt,
52+
sp: Span,
53+
tts: &[tokenstream::TokenTree])
54+
-> Box<base::MacResult + 'cx> {
5455
if !cx.ecfg.enable_asm() {
55-
feature_gate::emit_feature_err(
56-
&cx.parse_sess.span_diagnostic, "asm", sp,
57-
feature_gate::GateIssue::Language,
58-
feature_gate::EXPLAIN_ASM);
56+
feature_gate::emit_feature_err(&cx.parse_sess.span_diagnostic,
57+
"asm",
58+
sp,
59+
feature_gate::GateIssue::Language,
60+
feature_gate::EXPLAIN_ASM);
5961
return DummyResult::expr(sp);
6062
}
6163

6264
// Split the tts before the first colon, to avoid `asm!("x": y)` being
6365
// parsed as `asm!(z)` with `z = "x": y` which is type ascription.
64-
let first_colon = tts.iter().position(|tt| {
65-
match *tt {
66-
tokenstream::TokenTree::Token(_, token::Colon) |
67-
tokenstream::TokenTree::Token(_, token::ModSep) => true,
68-
_ => false
69-
}
70-
}).unwrap_or(tts.len());
66+
let first_colon = tts.iter()
67+
.position(|tt| {
68+
match *tt {
69+
tokenstream::TokenTree::Token(_, token::Colon) |
70+
tokenstream::TokenTree::Token(_, token::ModSep) => true,
71+
_ => false,
72+
}
73+
})
74+
.unwrap_or(tts.len());
7175
let mut p = cx.new_parser_from_tts(&tts[first_colon..]);
7276
let mut asm = token::InternedString::new("");
7377
let mut asm_str_style = None;
@@ -91,8 +95,9 @@ pub fn expand_asm<'cx>(cx: &'cx mut ExtCtxt, sp: Span, tts: &[tokenstream::Token
9195
}
9296
// Nested parser, stop before the first colon (see above).
9397
let mut p2 = cx.new_parser_from_tts(&tts[..first_colon]);
94-
let (s, style) = match expr_to_string(cx, panictry!(p2.parse_expr()),
95-
"inline assembly must be a string literal") {
98+
let (s, style) = match expr_to_string(cx,
99+
panictry!(p2.parse_expr()),
100+
"inline assembly must be a string literal") {
96101
Some((s, st)) => (s, st),
97102
// let compilation continue
98103
None => return DummyResult::expr(sp),
@@ -109,9 +114,7 @@ pub fn expand_asm<'cx>(cx: &'cx mut ExtCtxt, sp: Span, tts: &[tokenstream::Token
109114
asm_str_style = Some(style);
110115
}
111116
Outputs => {
112-
while p.token != token::Eof &&
113-
p.token != token::Colon &&
114-
p.token != token::ModSep {
117+
while p.token != token::Eof && p.token != token::Colon && p.token != token::ModSep {
115118

116119
if !outputs.is_empty() {
117120
p.eat(&token::Comma);
@@ -136,8 +139,7 @@ pub fn expand_asm<'cx>(cx: &'cx mut ExtCtxt, sp: Span, tts: &[tokenstream::Token
136139
let output = match ch.next() {
137140
Some('=') => None,
138141
Some('+') => {
139-
Some(token::intern_and_get_ident(&format!(
140-
"={}", ch.as_str())))
142+
Some(token::intern_and_get_ident(&format!("={}", ch.as_str())))
141143
}
142144
_ => {
143145
cx.span_err(span, "output operand constraint lacks '=' or '+'");
@@ -156,9 +158,7 @@ pub fn expand_asm<'cx>(cx: &'cx mut ExtCtxt, sp: Span, tts: &[tokenstream::Token
156158
}
157159
}
158160
Inputs => {
159-
while p.token != token::Eof &&
160-
p.token != token::Colon &&
161-
p.token != token::ModSep {
161+
while p.token != token::Eof && p.token != token::Colon && p.token != token::ModSep {
162162

163163
if !inputs.is_empty() {
164164
p.eat(&token::Comma);
@@ -180,9 +180,7 @@ pub fn expand_asm<'cx>(cx: &'cx mut ExtCtxt, sp: Span, tts: &[tokenstream::Token
180180
}
181181
}
182182
Clobbers => {
183-
while p.token != token::Eof &&
184-
p.token != token::Colon &&
185-
p.token != token::ModSep {
183+
while p.token != token::Eof && p.token != token::Colon && p.token != token::ModSep {
186184

187185
if !clobs.is_empty() {
188186
p.eat(&token::Comma);
@@ -218,25 +216,25 @@ pub fn expand_asm<'cx>(cx: &'cx mut ExtCtxt, sp: Span, tts: &[tokenstream::Token
218216
p.eat(&token::Comma);
219217
}
220218
}
221-
StateNone => ()
219+
StateNone => (),
222220
}
223221

224222
loop {
225223
// MOD_SEP is a double colon '::' without space in between.
226224
// When encountered, the state must be advanced twice.
227225
match (&p.token, state.next(), state.next().next()) {
228-
(&token::Colon, StateNone, _) |
226+
(&token::Colon, StateNone, _) |
229227
(&token::ModSep, _, StateNone) => {
230228
p.bump();
231229
break 'statement;
232230
}
233-
(&token::Colon, st, _) |
231+
(&token::Colon, st, _) |
234232
(&token::ModSep, _, st) => {
235233
p.bump();
236234
state = st;
237235
}
238236
(&token::Eof, _, _) => break 'statement,
239-
_ => break
237+
_ => break,
240238
}
241239
}
242240
}

src/libsyntax_ext/cfg.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ use syntax_pos::Span;
2323
pub fn expand_cfg<'cx>(cx: &mut ExtCtxt,
2424
sp: Span,
2525
tts: &[tokenstream::TokenTree])
26-
-> Box<base::MacResult+'static> {
26+
-> Box<base::MacResult + 'static> {
2727
let mut p = cx.new_parser_from_tts(tts);
2828
let cfg = panictry!(p.parse_meta_item());
2929

src/libsyntax_ext/concat.rs

+3-5
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ use std::string::String;
2020
pub fn expand_syntax_ext(cx: &mut base::ExtCtxt,
2121
sp: syntax_pos::Span,
2222
tts: &[tokenstream::TokenTree])
23-
-> Box<base::MacResult+'static> {
23+
-> Box<base::MacResult + 'static> {
2424
let es = match base::get_exprs_from_tts(cx, sp, tts) {
2525
Some(e) => e,
26-
None => return base::DummyResult::expr(sp)
26+
None => return base::DummyResult::expr(sp),
2727
};
2828
let mut accumulator = String::new();
2929
for e in es {
@@ -57,7 +57,5 @@ pub fn expand_syntax_ext(cx: &mut base::ExtCtxt,
5757
}
5858
}
5959
}
60-
base::MacEager::expr(cx.expr_str(
61-
sp,
62-
token::intern_and_get_ident(&accumulator[..])))
60+
base::MacEager::expr(cx.expr_str(sp, token::intern_and_get_ident(&accumulator[..])))
6361
}

src/libsyntax_ext/concat_idents.rs

+22-12
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,10 @@ use syntax::ptr::P;
1818
use syntax_pos::Span;
1919
use syntax::tokenstream::TokenTree;
2020

21-
pub fn expand_syntax_ext<'cx>(cx: &'cx mut ExtCtxt, sp: Span, tts: &[TokenTree])
22-
-> Box<base::MacResult+'cx> {
21+
pub fn expand_syntax_ext<'cx>(cx: &'cx mut ExtCtxt,
22+
sp: Span,
23+
tts: &[TokenTree])
24+
-> Box<base::MacResult + 'cx> {
2325
if !cx.ecfg.enable_concat_idents() {
2426
feature_gate::emit_feature_err(&cx.parse_sess.span_diagnostic,
2527
"concat_idents",
@@ -33,35 +35,40 @@ pub fn expand_syntax_ext<'cx>(cx: &'cx mut ExtCtxt, sp: Span, tts: &[TokenTree])
3335
for (i, e) in tts.iter().enumerate() {
3436
if i & 1 == 1 {
3537
match *e {
36-
TokenTree::Token(_, token::Comma) => {},
38+
TokenTree::Token(_, token::Comma) => {}
3739
_ => {
3840
cx.span_err(sp, "concat_idents! expecting comma.");
3941
return DummyResult::expr(sp);
40-
},
42+
}
4143
}
4244
} else {
4345
match *e {
44-
TokenTree::Token(_, token::Ident(ident)) => {
45-
res_str.push_str(&ident.name.as_str())
46-
},
46+
TokenTree::Token(_, token::Ident(ident)) => res_str.push_str(&ident.name.as_str()),
4747
_ => {
4848
cx.span_err(sp, "concat_idents! requires ident args.");
4949
return DummyResult::expr(sp);
50-
},
50+
}
5151
}
5252
}
5353
}
5454
let res = str_to_ident(&res_str);
5555

56-
struct Result { ident: ast::Ident, span: Span };
56+
struct Result {
57+
ident: ast::Ident,
58+
span: Span,
59+
};
5760

5861
impl Result {
5962
fn path(&self) -> ast::Path {
6063
let segment = ast::PathSegment {
6164
identifier: self.ident,
62-
parameters: ast::PathParameters::none()
65+
parameters: ast::PathParameters::none(),
6366
};
64-
ast::Path { span: self.span, global: false, segments: vec![segment] }
67+
ast::Path {
68+
span: self.span,
69+
global: false,
70+
segments: vec![segment],
71+
}
6572
}
6673
}
6774

@@ -84,5 +91,8 @@ pub fn expand_syntax_ext<'cx>(cx: &'cx mut ExtCtxt, sp: Span, tts: &[TokenTree])
8491
}
8592
}
8693

87-
Box::new(Result { ident: res, span: sp })
94+
Box::new(Result {
95+
ident: res,
96+
span: sp,
97+
})
8898
}

0 commit comments

Comments
 (0)