Format with rustfmt 0.99.5-nightly

This commit is contained in:
David Tolnay 2018-10-02 21:01:30 -07:00
parent 6c086fc748
commit fb84fc060e
No known key found for this signature in database
GPG Key ID: F9BA143B95FF6D82
9 changed files with 76 additions and 44 deletions

View File

@ -656,20 +656,24 @@ mod value {
_ => {}
},
b'\'' => return Lit::Char(LitChar { token: token }),
b'0'...b'9' => if number_is_int(&value) {
return Lit::Int(LitInt { token: token });
} else if number_is_float(&value) {
return Lit::Float(LitFloat { token: token });
} else {
// number overflow
return Lit::Verbatim(LitVerbatim { token: token });
},
_ => if value == "true" || value == "false" {
return Lit::Bool(LitBool {
value: value == "true",
span: token.span(),
});
},
b'0'...b'9' => {
if number_is_int(&value) {
return Lit::Int(LitInt { token: token });
} else if number_is_float(&value) {
return Lit::Float(LitFloat { token: token });
} else {
// number overflow
return Lit::Verbatim(LitVerbatim { token: token });
}
}
_ => {
if value == "true" || value == "false" {
return Lit::Bool(LitBool {
value: value == "true",
span: token.span(),
});
}
}
}
panic!("Unrecognized literal: {}", value);

View File

@ -114,11 +114,13 @@ impl<'a> Lookahead1<'a> {
pub fn error(self) -> Error {
let comparisons = self.comparisons.borrow();
match comparisons.len() {
0 => if self.cursor.eof() {
Error::new(self.scope, "unexpected end of input")
} else {
Error::new(self.cursor.span(), "unexpected token")
},
0 => {
if self.cursor.eof() {
Error::new(self.scope, "unexpected end of input")
} else {
Error::new(self.cursor.span(), "unexpected token")
}
}
1 => {
let message = format!("expected {}", comparisons[0]);
error::new_at(self.scope, self.cursor, message)

View File

@ -358,7 +358,8 @@ fn skip(input: ParseStream) -> bool {
} else {
Ok((false, *cursor))
}
}).unwrap()
})
.unwrap()
}
impl private {

View File

@ -130,11 +130,14 @@ where
fn span(&self) -> Span {
let mut tokens = TokenStream::new();
self.to_tokens(&mut tokens);
tokens.into_iter().fold(None::<Span>, |span, tt| {
check_invalid_span(tt.span()).map_or(span, |new_span| {
span.map(|span| span.join(new_span).unwrap_or(span))
tokens
.into_iter()
.fold(None::<Span>, |span, tt| {
check_invalid_span(tt.span()).map_or(span, |new_span| {
span.map(|span| span.join(new_span).unwrap_or(span))
})
})
}).unwrap_or(Span::call_site())
.unwrap_or(Span::call_site())
}
#[cfg(not(procmacro2_semver_exempt))]
@ -144,7 +147,10 @@ where
// We can't join spans without procmacro2_semver_exempt so just grab the
// first one.
tokens.into_iter().next().and_then(|tt| check_invalid_span(tt.span()))
tokens
.into_iter()
.next()
.and_then(|tt| check_invalid_span(tt.span()))
.unwrap_or(Span::call_site())
}
}

View File

@ -29,7 +29,8 @@ pub fn libsyntax_expr(input: &str) -> Option<P<ast::Expr>> {
&sess,
FileName::Custom("test_precedence".to_string()),
input.to_string(),
).parse_expr();
)
.parse_expr();
match e {
Ok(expr) => Some(expr),
Err(mut diagnostic) => {

View File

@ -102,7 +102,8 @@ fn test_struct() {
ty: TypePath {
qself: None,
path: ident("Ident").into(),
}.into(),
}
.into(),
},
Field {
ident: Some(ident("attrs")),
@ -132,7 +133,8 @@ fn test_struct() {
),
},],
},
}.into(),
}
.into(),
},
],
}),
@ -150,7 +152,8 @@ fn test_struct() {
NestedMeta::Meta(Meta::Word(ident("Debug"))),
NestedMeta::Meta(Meta::Word(ident("Clone"))),
],
}.into();
}
.into();
assert_eq!(
expected_meta_item,
@ -197,7 +200,8 @@ fn test_union() {
ty: TypeTuple {
paren_token: Default::default(),
elems: Punctuated::new(),
}.into(),
}
.into(),
},
Field {
ident: Some(ident("value")),
@ -207,7 +211,8 @@ fn test_union() {
ty: TypePath {
qself: None,
path: ident("T").into(),
}.into(),
}
.into(),
},
],
},
@ -300,7 +305,8 @@ fn test_enum() {
ty: TypePath {
qself: None,
path: ident("T").into(),
}.into(),
}
.into(),
},],
}),
discriminant: None,
@ -318,7 +324,8 @@ fn test_enum() {
ty: TypePath {
qself: None,
path: ident("E").into(),
}.into(),
}
.into(),
},],
}),
discriminant: None,
@ -387,7 +394,8 @@ fn test_enum() {
" See the std::result module documentation for details.",
Span::call_site(),
)),
}.into(),
}
.into(),
Meta::Word(ident("must_use")),
];
@ -572,7 +580,8 @@ fn test_pub_restricted() {
ty: TypePath {
qself: None,
path: ident("u8").into(),
}.into(),
}
.into(),
},],
}),
semi_token: Some(Default::default()),

View File

@ -64,7 +64,8 @@ fn test_split_for_impl() {
TypeTuple {
elems: Default::default(),
paren_token: Default::default(),
}.into(),
}
.into(),
),
colon_token: Some(Default::default()),
eq_token: Default::default(),
@ -78,7 +79,8 @@ fn test_split_for_impl() {
bounded_ty: TypePath {
qself: None,
path: ident("T").into(),
}.into(),
}
.into(),
bounds: punctuated![TypeParamBound::Trait(TraitBound {
paren_token: None,
modifier: TraitBoundModifier::None,

View File

@ -45,12 +45,14 @@ fn test_grouping() {
TokenTree::Literal(Literal::i32_suffixed(2)),
TokenTree::Punct(Punct::new('+', Spacing::Alone)),
TokenTree::Literal(Literal::i32_suffixed(3)),
].into_iter()
]
.into_iter()
.collect(),
)),
TokenTree::Punct(Punct::new('*', Spacing::Alone)),
TokenTree::Literal(Literal::i32_suffixed(4)),
].into_iter()
]
.into_iter()
.collect();
assert_eq!(raw.to_string(), "1i32 + 2i32 + 3i32 * 4i32");

View File

@ -105,7 +105,8 @@ fn test_meta_item_list_name_value() {
ident: ident("bar").into(),
eq_token: Default::default(),
lit: lit(Literal::i32_unsuffixed(5)),
}.into(),
}
.into(),
)],
},
)
@ -126,7 +127,8 @@ fn test_meta_item_list_bool_value() {
value: true,
span: Span::call_site()
}),
}.into(),
}
.into(),
)],
},
)
@ -146,7 +148,8 @@ fn test_meta_item_multiple() {
ident: ident("name").into(),
eq_token: Default::default(),
lit: lit(Literal::i32_unsuffixed(5)),
}.into(),
}
.into(),
),
NestedMeta::Meta(
MetaList {
@ -157,9 +160,11 @@ fn test_meta_item_multiple() {
ident: ident("name2").into(),
eq_token: Default::default(),
lit: lit(Literal::i32_unsuffixed(6)),
}.into(),
}
.into(),
)],
}.into(),
}
.into(),
),
NestedMeta::Meta(Meta::Word(ident("word2").into())),
],