Format with rustfmt 0.4.1
diff --git a/tests/common/parse.rs b/tests/common/parse.rs
index 989e407..31c2759 100644
--- a/tests/common/parse.rs
+++ b/tests/common/parse.rs
@@ -12,9 +12,9 @@
extern crate syntax_pos;
use self::syntax::ast;
-use self::syntax::ptr::P;
-use self::syntax::parse::{self, ParseSess};
use self::syntax::codemap::FilePathMapping;
+use self::syntax::parse::{self, ParseSess};
+use self::syntax::ptr::P;
use self::syntax_pos::FileName;
use std::panic;
diff --git a/tests/common/respan.rs b/tests/common/respan.rs
index a969ae2..4c1ad10 100644
--- a/tests/common/respan.rs
+++ b/tests/common/respan.rs
@@ -21,8 +21,8 @@
use self::syntax::util::move_map::MoveMap;
use self::syntax::util::small_vector::SmallVector;
-use self::syntax_pos::{Span, DUMMY_SP};
use self::syntax::ast;
+use self::syntax_pos::{Span, DUMMY_SP};
struct Respanner;
diff --git a/tests/test_derive_input.rs b/tests/test_derive_input.rs
index 460e9ca..61e4f7c 100644
--- a/tests/test_derive_input.rs
+++ b/tests/test_derive_input.rs
@@ -11,10 +11,10 @@
extern crate proc_macro2;
extern crate syn;
-use syn::*;
-use proc_macro2::{Delimiter, Literal, Spacing, Span, Term, Op, TokenStream, TokenTree};
-use proc_macro2::Group;
use proc_macro2::Delimiter::{Brace, Parenthesis};
+use proc_macro2::Group;
+use proc_macro2::{Delimiter, Literal, Op, Spacing, Span, Term, TokenStream, TokenTree};
+use syn::*;
use std::iter::FromIterator;
@@ -129,7 +129,7 @@
gt_token: Default::default(),
},
),
- }
+ },
],
},
}.into(),
@@ -152,7 +152,10 @@
],
}.into();
- assert_eq!(expected_meta_item, actual.attrs[0].interpret_meta().unwrap());
+ assert_eq!(
+ expected_meta_item,
+ actual.attrs[0].interpret_meta().unwrap()
+ );
}
#[test]
diff --git a/tests/test_grouping.rs b/tests/test_grouping.rs
index ca686f6..fde9d5a 100644
--- a/tests/test_grouping.rs
+++ b/tests/test_grouping.rs
@@ -11,8 +11,8 @@
#[macro_use]
extern crate syn;
-use syn::{BinOp, Expr, ExprBinary, ExprGroup, ExprLit, Lit};
use syn::token::Group;
+use syn::{BinOp, Expr, ExprBinary, ExprGroup, ExprLit, Lit};
extern crate proc_macro2;
use proc_macro2::*;
diff --git a/tests/test_lit.rs b/tests/test_lit.rs
index 79a0606..b974b30 100644
--- a/tests/test_lit.rs
+++ b/tests/test_lit.rs
@@ -10,10 +10,10 @@
extern crate quote;
extern crate syn;
-use syn::{FloatSuffix, IntSuffix, Lit};
+use proc_macro2::{TokenStream, TokenTree};
use quote::ToTokens;
-use proc_macro2::{TokenTree, TokenStream};
use std::str::FromStr;
+use syn::{FloatSuffix, IntSuffix, Lit};
fn lit(s: &str) -> Lit {
match TokenStream::from_str(s)
diff --git a/tests/test_meta_item.rs b/tests/test_meta_item.rs
index bd2c1a5..22a38fb 100644
--- a/tests/test_meta_item.rs
+++ b/tests/test_meta_item.rs
@@ -11,9 +11,9 @@
extern crate proc_macro2;
extern crate syn;
-use syn::*;
-use syn::buffer::TokenBuffer;
use proc_macro2::{Literal, Span, TokenStream};
+use syn::buffer::TokenBuffer;
+use syn::*;
#[macro_use]
mod macros;
@@ -46,7 +46,10 @@
MetaNameValue {
ident: "foo".into(),
eq_token: Default::default(),
- lit: Lit::Bool(LitBool { value: true, span: Span::call_site() }),
+ lit: Lit::Bool(LitBool {
+ value: true,
+ span: Span::call_site(),
+ }),
},
);
run_test(
@@ -54,7 +57,10 @@
MetaNameValue {
ident: "foo".into(),
eq_token: Default::default(),
- lit: Lit::Bool(LitBool { value: false, span: Span::call_site() }),
+ lit: Lit::Bool(LitBool {
+ value: false,
+ span: Span::call_site(),
+ }),
},
)
}
@@ -115,7 +121,10 @@
MetaNameValue {
ident: "bar".into(),
eq_token: Default::default(),
- lit: Lit::Bool(LitBool { value: true, span: Span::call_site() }),
+ lit: Lit::Bool(LitBool {
+ value: true,
+ span: Span::call_site()
+ }),
}.into(),
),
],
diff --git a/tests/test_precedence.rs b/tests/test_precedence.rs
index 6c2d74c..2fea96b 100644
--- a/tests/test_precedence.rs
+++ b/tests/test_precedence.rs
@@ -162,34 +162,36 @@
let mut passed = 0;
let mut failed = 0;
- syntax::with_globals(|| for expr in exprs {
- let raw = quote!(#expr).to_string();
+ syntax::with_globals(|| {
+ for expr in exprs {
+ let raw = quote!(#expr).to_string();
- let libsyntax_ast = if let Some(e) = libsyntax_parse_and_rewrite(&raw) {
- e
- } else {
- failed += 1;
- errorf!("\nFAIL - libsyntax failed to parse raw\n");
- continue;
- };
+ let libsyntax_ast = if let Some(e) = libsyntax_parse_and_rewrite(&raw) {
+ e
+ } else {
+ failed += 1;
+ errorf!("\nFAIL - libsyntax failed to parse raw\n");
+ continue;
+ };
- let syn_expr = syn_brackets(expr);
- let syn_ast = if let Some(e) = parse::libsyntax_expr("e!(#syn_expr).to_string()) {
- e
- } else {
- failed += 1;
- errorf!("\nFAIL - libsyntax failed to parse bracketed\n");
- continue;
- };
+ let syn_expr = syn_brackets(expr);
+ let syn_ast = if let Some(e) = parse::libsyntax_expr("e!(#syn_expr).to_string()) {
+ e
+ } else {
+ failed += 1;
+ errorf!("\nFAIL - libsyntax failed to parse bracketed\n");
+ continue;
+ };
- let syn_ast = respan::respan_expr(syn_ast);
- let libsyntax_ast = respan::respan_expr(libsyntax_ast);
+ let syn_ast = respan::respan_expr(syn_ast);
+ let libsyntax_ast = respan::respan_expr(libsyntax_ast);
- if syn_ast == libsyntax_ast {
- passed += 1;
- } else {
- failed += 1;
- errorf!("\nFAIL\n{:?}\n!=\n{:?}\n", syn_ast, libsyntax_ast);
+ if syn_ast == libsyntax_ast {
+ passed += 1;
+ } else {
+ failed += 1;
+ errorf!("\nFAIL\n{:?}\n!=\n{:?}\n", syn_ast, libsyntax_ast);
+ }
}
});
@@ -207,11 +209,11 @@
/// This method operates on libsyntax objects.
fn libsyntax_brackets(libsyntax_expr: P<ast::Expr>) -> Option<P<ast::Expr>> {
use syntax::ast::{Expr, ExprKind, Field, Mac, Pat, Stmt, StmtKind, Ty};
+ use syntax::codemap;
+ use syntax::ext::quote::rt::DUMMY_SP;
use syntax::fold::{self, Folder};
use syntax::util::ThinVec;
use syntax::util::small_vector::SmallVector;
- use syntax::ext::quote::rt::DUMMY_SP;
- use syntax::codemap;
fn expr(node: ExprKind) -> P<Expr> {
P(Expr {
@@ -300,8 +302,8 @@
/// reveal the precedence of the parsed expressions, and produce a stringified form
/// of the resulting expression.
fn syn_brackets(syn_expr: syn::Expr) -> syn::Expr {
- use syn::*;
use syn::fold::*;
+ use syn::*;
fn paren(folder: &mut ParenthesizeEveryExpr, mut node: Expr) -> Expr {
let attrs = node.replace_attrs(Vec::new());
@@ -352,9 +354,9 @@
/// Walk through a crate collecting all expressions we can find in it.
fn collect_exprs(file: syn::File) -> Vec<syn::Expr> {
- use syn::*;
use syn::fold::*;
use syn::punctuated::Punctuated;
+ use syn::*;
struct CollectExprs(Vec<Expr>);
impl Fold for CollectExprs {
diff --git a/tests/test_round_trip.rs b/tests/test_round_trip.rs
index a6013ce..92e84e5 100644
--- a/tests/test_round_trip.rs
+++ b/tests/test_round_trip.rs
@@ -19,8 +19,8 @@
use rayon::iter::{IntoParallelIterator, ParallelIterator};
use syntax::ast;
-use syntax::parse::{self, PResult, ParseSess};
use syntax::codemap::FilePathMapping;
+use syntax::parse::{self, PResult, ParseSess};
use syntax_pos::FileName;
use walkdir::{DirEntry, WalkDir};
@@ -79,53 +79,56 @@
};
let back = quote!(#krate).to_string();
- let equal = panic::catch_unwind(|| syntax::with_globals(|| {
- let sess = ParseSess::new(FilePathMapping::empty());
- let before = match libsyntax_parse(content, &sess) {
- Ok(before) => before,
- Err(mut diagnostic) => {
- diagnostic.cancel();
- if diagnostic
- .message()
- .starts_with("file not found for module")
- {
- errorf!("=== {}: ignore\n", path.display());
- } else {
- errorf!(
+ let equal = panic::catch_unwind(|| {
+ syntax::with_globals(|| {
+ let sess = ParseSess::new(FilePathMapping::empty());
+ let before = match libsyntax_parse(content, &sess) {
+ Ok(before) => before,
+ Err(mut diagnostic) => {
+ diagnostic.cancel();
+ if diagnostic
+ .message()
+ .starts_with("file not found for module")
+ {
+ errorf!("=== {}: ignore\n", path.display());
+ } else {
+ errorf!(
"=== {}: ignore - libsyntax failed to parse original content: {}\n",
path.display(),
diagnostic.message()
);
+ }
+ return true;
}
- return true;
- }
- };
- let after = match libsyntax_parse(back, &sess) {
- Ok(after) => after,
- Err(mut diagnostic) => {
- errorf!("=== {}: libsyntax failed to parse", path.display());
- diagnostic.emit();
- return false;
- }
- };
+ };
+ let after = match libsyntax_parse(back, &sess) {
+ Ok(after) => after,
+ Err(mut diagnostic) => {
+ errorf!("=== {}: libsyntax failed to parse", path.display());
+ diagnostic.emit();
+ return false;
+ }
+ };
- if before == after {
- errorf!(
- "=== {}: pass in {}ms\n",
- path.display(),
- elapsed.as_secs() * 1000 + u64::from(elapsed.subsec_nanos()) / 1_000_000
- );
- true
- } else {
- errorf!(
- "=== {}: FAIL\nbefore: {}\nafter: {}\n",
- path.display(),
- format!("{:?}", before).replace("\n", ""),
- format!("{:?}", after).replace("\n", "")
- );
- false
- }
- }));
+ if before == after {
+ errorf!(
+ "=== {}: pass in {}ms\n",
+ path.display(),
+ elapsed.as_secs() * 1000
+ + u64::from(elapsed.subsec_nanos()) / 1_000_000
+ );
+ true
+ } else {
+ errorf!(
+ "=== {}: FAIL\nbefore: {}\nafter: {}\n",
+ path.display(),
+ format!("{:?}", before).replace("\n", ""),
+ format!("{:?}", after).replace("\n", "")
+ );
+ false
+ }
+ })
+ });
match equal {
Err(_) => errorf!("=== {}: ignoring libsyntax panic\n", path.display()),
Ok(true) => {}
diff --git a/tests/test_token_trees.rs b/tests/test_token_trees.rs
index 6fbb4ae..1bd9d1c 100644
--- a/tests/test_token_trees.rs
+++ b/tests/test_token_trees.rs
@@ -13,9 +13,9 @@
extern crate quote;
extern crate syn;
-use syn::{AttrStyle, Attribute, Lit};
-use proc_macro2::{Delimiter, Spacing, Span, Term, Op, Group, TokenStream, TokenTree};
use proc_macro2::Delimiter::*;
+use proc_macro2::{Delimiter, Group, Op, Spacing, Span, Term, TokenStream, TokenTree};
+use syn::{AttrStyle, Attribute, Lit};
fn alone(c: char) -> TokenTree {
Op::new(c, Spacing::Alone).into()