Test with libsyntax instead of syntex
diff --git a/tests/common/parse.rs b/tests/common/parse.rs
index a0c54e5..e02e011 100644
--- a/tests/common/parse.rs
+++ b/tests/common/parse.rs
@@ -1,18 +1,18 @@
extern crate proc_macro2;
extern crate syn;
extern crate synom;
-extern crate syntex_syntax;
+extern crate syntax;
-use self::syntex_syntax::ast;
-use self::syntex_syntax::ptr::P;
-use self::syntex_syntax::parse::{self, ParseSess};
-use self::syntex_syntax::codemap::FilePathMapping;
+use self::syntax::ast;
+use self::syntax::ptr::P;
+use self::syntax::parse::{self, ParseSess};
+use self::syntax::codemap::FilePathMapping;
use std::panic;
use self::synom::{Synom, SynomBuffer};
-pub fn syntex_expr(input: &str) -> Option<P<ast::Expr>> {
+pub fn libsyntax_expr(input: &str) -> Option<P<ast::Expr>> {
match panic::catch_unwind(|| {
let sess = ParseSess::new(FilePathMapping::empty());
sess.span_diagnostic.set_continue_after_error(false);
@@ -34,7 +34,7 @@
None
}
Err(_) => {
- errorf!("syntex paniced\n");
+ errorf!("libsyntax paniced\n");
None
}
}
diff --git a/tests/common/respan.rs b/tests/common/respan.rs
index 0d5eeb3..c191238 100644
--- a/tests/common/respan.rs
+++ b/tests/common/respan.rs
@@ -1,22 +1,22 @@
-extern crate syntex_syntax;
-extern crate syntex_pos;
+extern crate syntax;
+extern crate syntax_pos;
use std::rc::Rc;
-use self::syntex_syntax::ast::{Attribute, Expr, ExprKind, Field, FnDecl, FunctionRetTy, ImplItem,
- ImplItemKind, ItemKind, Mac, MetaItem, MetaItemKind, MethodSig,
- NestedMetaItem, NestedMetaItemKind, TraitItem, TraitItemKind, TyParam,
- Visibility};
-use self::syntex_syntax::codemap::{self, Spanned};
-use self::syntex_syntax::fold::{self, Folder};
-use self::syntex_syntax::parse::token::{Lit, Token};
-use self::syntex_syntax::ptr::P;
-use self::syntex_syntax::symbol::Symbol;
-use self::syntex_syntax::tokenstream::{Delimited, TokenTree};
-use self::syntex_syntax::util::move_map::MoveMap;
-use self::syntex_syntax::util::small_vector::SmallVector;
+use self::syntax::ast::{Attribute, Expr, ExprKind, Field, FnDecl, FunctionRetTy, ImplItem,
+ ImplItemKind, ItemKind, Mac, MetaItem, MetaItemKind, MethodSig,
+ NestedMetaItem, NestedMetaItemKind, TraitItem, TraitItemKind, TyParam,
+ Visibility};
+use self::syntax::codemap::{self, Spanned};
+use self::syntax::fold::{self, Folder};
+use self::syntax::parse::token::{Lit, Token};
+use self::syntax::ptr::P;
+use self::syntax::symbol::Symbol;
+use self::syntax::tokenstream::{Delimited, TokenTree};
+use self::syntax::util::move_map::MoveMap;
+use self::syntax::util::small_vector::SmallVector;
-use self::syntex_pos::{Span, DUMMY_SP};
-use self::syntex_syntax::ast;
+use self::syntax_pos::{Span, DUMMY_SP};
+use self::syntax::ast;
struct Respanner;
diff --git a/tests/test_precedence.rs b/tests/test_precedence.rs
index 19dc3ad..0bddd39 100644
--- a/tests/test_precedence.rs
+++ b/tests/test_precedence.rs
@@ -2,12 +2,12 @@
//! The tests in this module do the following:
//!
-//! 1. Parse a given expression in both `syn` and `syntex`.
+//! 1. Parse a given expression in both `syn` and `libsyntax`.
//! 2. Fold over the expression adding brackets around each subexpression (with
-//! some complications - see the `syn_brackets` and `syntex_brackets`
+//! some complications - see the `syn_brackets` and `libsyntax_brackets`
//! methods).
//! 3. Serialize the `syn` expression back into a string, and re-parse it with
-//! `syntex`.
+//! `libsyntax`.
//! 4. Respan all of the expressions, replacing the spans with the default spans.
//! 5. Compare the expressions with one another, if they are not equal fail.
@@ -15,11 +15,11 @@
extern crate quote;
extern crate syn;
extern crate synom;
-extern crate syntex_syntax;
+extern crate syntax;
extern crate walkdir;
-use syntex_syntax::ast;
-use syntex_syntax::ptr::P;
+use syntax::ast;
+use syntax::ptr::P;
use common::{respan, parse};
@@ -90,7 +90,7 @@
continue;
}
- // Our version of `syntex_syntax` can't parse this tests
+ // Our version of `libsyntax` can't parse this tests
if path.to_str().unwrap().ends_with("optional_comma_in_match_arm.rs") {
continue
}
@@ -138,53 +138,53 @@
for expr in exprs {
let raw = quote!(#expr).to_string();
- let syntex_ast = if let Some(e) = syntex_parse_and_rewrite(&raw) {
+ let libsyntax_ast = if let Some(e) = libsyntax_parse_and_rewrite(&raw) {
e
} else {
failed += 1;
- errorf!("\nFAIL - syntex failed to parse raw\n");
+ errorf!("\nFAIL - libsyntax failed to parse raw\n");
continue;
};
let syn_expr = syn_brackets(expr);
- let syn_ast = if let Some(e) = parse::syntex_expr("e!(#syn_expr).to_string()) {
+ let syn_ast = if let Some(e) = parse::libsyntax_expr("e!(#syn_expr).to_string()) {
e
} else {
failed += 1;
- errorf!("\nFAIL - syntex failed to parse bracketed\n");
+ errorf!("\nFAIL - libsyntax failed to parse bracketed\n");
continue;
};
let syn_ast = respan::respan_expr(syn_ast);
- let syntex_ast = respan::respan_expr(syntex_ast);
+ let libsyntax_ast = respan::respan_expr(libsyntax_ast);
- if syn_ast == syntex_ast {
+ if syn_ast == libsyntax_ast {
passed += 1;
} else {
failed += 1;
- errorf!("\nFAIL\n{:?}\n!=\n{:?}\n", syn_ast, syntex_ast);
+ errorf!("\nFAIL\n{:?}\n!=\n{:?}\n", syn_ast, libsyntax_ast);
}
}
(passed, failed)
}
-fn syntex_parse_and_rewrite(input: &str) -> Option<P<ast::Expr>> {
- parse::syntex_expr(input).and_then(|e| syntex_brackets(e))
+fn libsyntax_parse_and_rewrite(input: &str) -> Option<P<ast::Expr>> {
+ parse::libsyntax_expr(input).and_then(|e| libsyntax_brackets(e))
}
/// Wrap every expression which is not already wrapped in parens with parens, to
/// reveal the precidence of the parsed expressions, and produce a stringified form
/// of the resulting expression.
///
-/// This method operates on syntex objects.
-fn syntex_brackets(syntex_expr: P<ast::Expr>) -> Option<P<ast::Expr>> {
- use syntex_syntax::ast::{Expr, ExprKind, Mac, Stmt, StmtKind, Pat, Ty, Field};
- use syntex_syntax::fold::{self, Folder};
- use syntex_syntax::util::ThinVec;
- use syntex_syntax::util::small_vector::SmallVector;
- use syntex_syntax::ext::quote::rt::DUMMY_SP;
- use syntex_syntax::codemap;
+/// This method operates on libsyntax objects.
+fn libsyntax_brackets(libsyntax_expr: P<ast::Expr>) -> Option<P<ast::Expr>> {
+ use syntax::ast::{Expr, ExprKind, Mac, Stmt, StmtKind, Pat, Ty, Field};
+ 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 {
@@ -268,7 +268,7 @@
}
fn fold_mac(&mut self, mac: Mac) -> Mac {
- // By default when folding over macros, syntex panics. This is
+ // By default when folding over macros, libsyntax panics. This is
// because it's usually not what you want, you want to run after
// macro expansion. We do want to do that (syn doesn't do macro
// expansion), so we implement fold_mac to just return the macro
@@ -280,7 +280,7 @@
let mut folder = BracketsFolder {
failed: false,
};
- let e = folder.fold_expr(syntex_expr);
+ let e = folder.fold_expr(libsyntax_expr);
if folder.failed {
None
} else {
diff --git a/tests/test_round_trip.rs b/tests/test_round_trip.rs
index 541f91a..92154e8 100644
--- a/tests/test_round_trip.rs
+++ b/tests/test_round_trip.rs
@@ -1,14 +1,16 @@
#![cfg(feature = "full")]
+#![feature(rustc_private)]
+
#[macro_use]
extern crate quote;
extern crate syn;
-extern crate syntex_syntax;
+extern crate syntax;
extern crate walkdir;
-use syntex_syntax::ast;
-use syntex_syntax::parse::{self, ParseSess, PResult};
-use syntex_syntax::codemap::FilePathMapping;
+use syntax::ast;
+use syntax::parse::{self, ParseSess, PResult};
+use syntax::codemap::FilePathMapping;
use walkdir::{WalkDir, WalkDirIterator};
use std::fs::File;
@@ -61,22 +63,22 @@
let equal = panic::catch_unwind(|| {
let sess = ParseSess::new(FilePathMapping::empty());
- let before = match syntex_parse(content, &sess) {
+ 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");
} else {
- errorf!("ignore - syntex failed to parse original content: {}\n", diagnostic.message());
+ errorf!("ignore - libsyntax failed to parse original content: {}\n", diagnostic.message());
}
return true;
}
};
- let after = match syntex_parse(back, &sess) {
+ let after = match libsyntax_parse(back, &sess) {
Ok(after) => after,
Err(mut diagnostic) => {
- errorf!("syntex failed to parse");
+ errorf!("libsyntax failed to parse");
diagnostic.emit();
return false;
}
@@ -94,7 +96,7 @@
}
});
match equal {
- Err(_) => errorf!("ignoring syntex panic\n"),
+ Err(_) => errorf!("ignoring libsyntax panic\n"),
Ok(true) => {}
Ok(false) => {
failed += 1;
@@ -110,7 +112,7 @@
}
}
-fn syntex_parse(content: String, sess: &ParseSess) -> PResult<ast::Crate> {
+fn libsyntax_parse(content: String, sess: &ParseSess) -> PResult<ast::Crate> {
let name = "test_round_trip".to_string();
parse::parse_crate_from_source_str(name, content, sess)
.map(common::respan::respan_crate)