diff options
| author | bors <bors@rust-lang.org> | 2016-06-27 16:42:03 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2016-06-27 16:42:03 -0700 |
| commit | ea0dc9297283daff6486807f43e190b4eb561412 (patch) | |
| tree | d184776089de9911ae9e983cc692021498e21a25 /src/libsyntax_ext | |
| parent | a0f572e98bacc719aa211b1fe97c61339cf6c93a (diff) | |
| parent | 360dcae4197d0bf0f59d5364470e00b589d5c549 (diff) | |
| download | rust-ea0dc9297283daff6486807f43e190b4eb561412.tar.gz rust-ea0dc9297283daff6486807f43e190b4eb561412.zip | |
Auto merge of #34424 - jseyfried:breaking_batch, r=Manishearth
Batch up libsyntax breaking changes Batch of the following syntax-[breaking-change] changes: - #34213: Add a variant `Macro` to `TraitItemKind` - #34368: Merge the variant `QPath` of `PatKind` into the variant `PatKind::Path` - #34385: Move `syntax::ast::TokenTree` into a new module `syntax::tokenstream` - #33943: - Remove the type parameter from `visit::Visitor` - Remove `attr::WithAttrs` -- use `attr::HasAttrs` instead. - Change `fold_tt`/`fold_tts` to take token trees by value and avoid wrapping token trees in `Rc`. - Remove the field `ctxt` of `ast::Mac_` - Remove inherent method `attrs()` of types -- use the method `attrs` of `HasAttrs` instead. - #34316: - Remove `ast::Decl`/`ast::DeclKind` and add variants `Local` and `Item` to `StmtKind`. - Move the node id for statements from the `StmtKind` variants to a field of `Stmt` (making `Stmt` a struct instead of an alias for `Spanned<StmtKind>`) - Rename `ast::ExprKind::Again` to `Continue`. - #34339: Generalize and abstract `ThinAttributes` to `ThinVec<Attribute>` - Use `.into()` in convert between `Vec<Attribute>` and `ThinVec<Attribute>` - Use autoderef instead of `.as_attr_slice()` - #34436: Remove the optional expression from `ast::Block` and instead use a `StmtKind::Expr` at the end of the statement list. - #34403: Move errors into a separate crate (unlikely to cause breakage)
Diffstat (limited to 'src/libsyntax_ext')
24 files changed, 80 insertions, 67 deletions
diff --git a/src/libsyntax_ext/Cargo.toml b/src/libsyntax_ext/Cargo.toml index 671f3e4a7e3..040c6c8ebff 100644 --- a/src/libsyntax_ext/Cargo.toml +++ b/src/libsyntax_ext/Cargo.toml @@ -12,3 +12,5 @@ crate-type = ["dylib"] fmt_macros = { path = "../libfmt_macros" } log = { path = "../liblog" } syntax = { path = "../libsyntax" } +syntax_pos = { path = "../libsyntax_pos" } +rustc_errors = { path = "../librustc_errors" } \ No newline at end of file diff --git a/src/libsyntax_ext/asm.rs b/src/libsyntax_ext/asm.rs index 50d2b9d31fe..56a8c28ffed 100644 --- a/src/libsyntax_ext/asm.rs +++ b/src/libsyntax_ext/asm.rs @@ -15,7 +15,6 @@ use self::State::*; use syntax::ast; use syntax::codemap; -use syntax::codemap::Span; use syntax::ext::base; use syntax::ext::base::*; use syntax::feature_gate; @@ -23,6 +22,8 @@ use syntax::parse::token::intern; use syntax::parse::{self, token}; use syntax::ptr::P; use syntax::ast::AsmDialect; +use syntax_pos::Span; +use syntax::tokenstream; enum State { Asm, @@ -48,7 +49,7 @@ impl State { const OPTIONS: &'static [&'static str] = &["volatile", "alignstack", "intel"]; -pub fn expand_asm<'cx>(cx: &'cx mut ExtCtxt, sp: Span, tts: &[ast::TokenTree]) +pub fn expand_asm<'cx>(cx: &'cx mut ExtCtxt, sp: Span, tts: &[tokenstream::TokenTree]) -> Box<base::MacResult+'cx> { if !cx.ecfg.enable_asm() { feature_gate::emit_feature_err( @@ -62,8 +63,8 @@ pub fn expand_asm<'cx>(cx: &'cx mut ExtCtxt, sp: Span, tts: &[ast::TokenTree]) // parsed as `asm!(z)` with `z = "x": y` which is type ascription. let first_colon = tts.iter().position(|tt| { match *tt { - ast::TokenTree::Token(_, token::Colon) | - ast::TokenTree::Token(_, token::ModSep) => true, + tokenstream::TokenTree::Token(_, token::Colon) | + tokenstream::TokenTree::Token(_, token::ModSep) => true, _ => false } }).unwrap_or(tts.len()); @@ -260,6 +261,6 @@ pub fn expand_asm<'cx>(cx: &'cx mut ExtCtxt, sp: Span, tts: &[ast::TokenTree]) expn_id: expn_id, }), span: sp, - attrs: None, + attrs: ast::ThinVec::new(), })) } diff --git a/src/libsyntax_ext/cfg.rs b/src/libsyntax_ext/cfg.rs index 593bf14a018..dbf23328f41 100644 --- a/src/libsyntax_ext/cfg.rs +++ b/src/libsyntax_ext/cfg.rs @@ -12,17 +12,17 @@ /// a literal `true` or `false` based on whether the given cfg matches the /// current compilation environment. -use syntax::ast; -use syntax::codemap::Span; use syntax::ext::base::*; use syntax::ext::base; use syntax::ext::build::AstBuilder; use syntax::attr; +use syntax::tokenstream; use syntax::parse::token; +use syntax_pos::Span; pub fn expand_cfg<'cx>(cx: &mut ExtCtxt, sp: Span, - tts: &[ast::TokenTree]) + tts: &[tokenstream::TokenTree]) -> Box<base::MacResult+'static> { let mut p = cx.new_parser_from_tts(tts); let cfg = panictry!(p.parse_meta_item()); diff --git a/src/libsyntax_ext/concat.rs b/src/libsyntax_ext/concat.rs index db731adf794..22c4aeefbd1 100644 --- a/src/libsyntax_ext/concat.rs +++ b/src/libsyntax_ext/concat.rs @@ -9,16 +9,17 @@ // except according to those terms. use syntax::ast; -use syntax::codemap; use syntax::ext::base; use syntax::ext::build::AstBuilder; use syntax::parse::token; +use syntax_pos; +use syntax::tokenstream; use std::string::String; pub fn expand_syntax_ext(cx: &mut base::ExtCtxt, - sp: codemap::Span, - tts: &[ast::TokenTree]) + sp: syntax_pos::Span, + tts: &[tokenstream::TokenTree]) -> Box<base::MacResult+'static> { let es = match base::get_exprs_from_tts(cx, sp, tts) { Some(e) => e, diff --git a/src/libsyntax_ext/concat_idents.rs b/src/libsyntax_ext/concat_idents.rs index 09c23682cd7..870413a7f61 100644 --- a/src/libsyntax_ext/concat_idents.rs +++ b/src/libsyntax_ext/concat_idents.rs @@ -8,14 +8,15 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use syntax::ast::{self, TokenTree}; -use syntax::codemap::Span; +use syntax::ast; use syntax::ext::base::*; use syntax::ext::base; use syntax::feature_gate; use syntax::parse::token; use syntax::parse::token::str_to_ident; use syntax::ptr::P; +use syntax_pos::Span; +use syntax::tokenstream::TokenTree; pub fn expand_syntax_ext<'cx>(cx: &'cx mut ExtCtxt, sp: Span, tts: &[TokenTree]) -> Box<base::MacResult+'cx> { @@ -70,7 +71,7 @@ pub fn expand_syntax_ext<'cx>(cx: &'cx mut ExtCtxt, sp: Span, tts: &[TokenTree]) id: ast::DUMMY_NODE_ID, node: ast::ExprKind::Path(None, self.path()), span: self.span, - attrs: None, + attrs: ast::ThinVec::new(), })) } diff --git a/src/libsyntax_ext/deriving/bounds.rs b/src/libsyntax_ext/deriving/bounds.rs index 9bc0e088110..36818e000b5 100644 --- a/src/libsyntax_ext/deriving/bounds.rs +++ b/src/libsyntax_ext/deriving/bounds.rs @@ -12,8 +12,8 @@ use deriving::generic::*; use deriving::generic::ty::*; use syntax::ast::MetaItem; -use syntax::codemap::Span; use syntax::ext::base::{ExtCtxt, Annotatable}; +use syntax_pos::Span; pub fn expand_deriving_unsafe_bound(cx: &mut ExtCtxt, span: Span, diff --git a/src/libsyntax_ext/deriving/clone.rs b/src/libsyntax_ext/deriving/clone.rs index 30fe0f2db8a..1e47ebb8583 100644 --- a/src/libsyntax_ext/deriving/clone.rs +++ b/src/libsyntax_ext/deriving/clone.rs @@ -13,11 +13,11 @@ use deriving::generic::ty::*; use syntax::ast::{Expr, ItemKind, Generics, MetaItem, VariantData}; use syntax::attr; -use syntax::codemap::Span; use syntax::ext::base::{ExtCtxt, Annotatable}; use syntax::ext::build::AstBuilder; use syntax::parse::token::InternedString; use syntax::ptr::P; +use syntax_pos::Span; #[derive(PartialEq)] enum Mode { Deep, Shallow } @@ -145,12 +145,10 @@ fn cs_clone( match mode { Mode::Shallow => { - cx.expr_block(cx.block(trait_span, - all_fields.iter() - .map(subcall) - .map(|e| cx.stmt_expr(e)) - .collect(), - Some(cx.expr_deref(trait_span, cx.expr_self(trait_span))))) + let mut stmts: Vec<_> = + all_fields.iter().map(subcall).map(|e| cx.stmt_expr(e)).collect(); + stmts.push(cx.stmt_expr(cx.expr_deref(trait_span, cx.expr_self(trait_span)))); + cx.expr_block(cx.block(trait_span, stmts)) } Mode::Deep => { match *vdata { diff --git a/src/libsyntax_ext/deriving/cmp/eq.rs b/src/libsyntax_ext/deriving/cmp/eq.rs index 8bd12c39337..9c5072eeb3e 100644 --- a/src/libsyntax_ext/deriving/cmp/eq.rs +++ b/src/libsyntax_ext/deriving/cmp/eq.rs @@ -12,11 +12,11 @@ use deriving::generic::*; use deriving::generic::ty::*; use syntax::ast::{MetaItem, Expr}; -use syntax::codemap::Span; use syntax::ext::base::{ExtCtxt, Annotatable}; use syntax::ext::build::AstBuilder; use syntax::parse::token::InternedString; use syntax::ptr::P; +use syntax_pos::Span; pub fn expand_deriving_eq(cx: &mut ExtCtxt, span: Span, @@ -30,7 +30,7 @@ pub fn expand_deriving_eq(cx: &mut ExtCtxt, // create `a.<method>(); b.<method>(); c.<method>(); ...` // (where method is `assert_receiver_is_total_eq`) let stmts = exprs.into_iter().map(|e| cx.stmt_expr(e)).collect(); - let block = cx.block(span, stmts, None); + let block = cx.block(span, stmts); cx.expr_block(block) }, Box::new(|cx, sp, _, _| { diff --git a/src/libsyntax_ext/deriving/cmp/ord.rs b/src/libsyntax_ext/deriving/cmp/ord.rs index 6133adb8fc5..cbd7ac0eada 100644 --- a/src/libsyntax_ext/deriving/cmp/ord.rs +++ b/src/libsyntax_ext/deriving/cmp/ord.rs @@ -12,11 +12,11 @@ use deriving::generic::*; use deriving::generic::ty::*; use syntax::ast::{MetaItem, Expr, self}; -use syntax::codemap::Span; use syntax::ext::base::{ExtCtxt, Annotatable}; use syntax::ext::build::AstBuilder; use syntax::parse::token::InternedString; use syntax::ptr::P; +use syntax_pos::Span; pub fn expand_deriving_ord(cx: &mut ExtCtxt, span: Span, diff --git a/src/libsyntax_ext/deriving/cmp/partial_eq.rs b/src/libsyntax_ext/deriving/cmp/partial_eq.rs index e5890d7213b..b5a8167fb55 100644 --- a/src/libsyntax_ext/deriving/cmp/partial_eq.rs +++ b/src/libsyntax_ext/deriving/cmp/partial_eq.rs @@ -12,11 +12,11 @@ use deriving::generic::*; use deriving::generic::ty::*; use syntax::ast::{MetaItem, Expr, BinOpKind}; -use syntax::codemap::Span; use syntax::ext::base::{ExtCtxt, Annotatable}; use syntax::ext::build::AstBuilder; use syntax::parse::token::InternedString; use syntax::ptr::P; +use syntax_pos::Span; pub fn expand_deriving_partial_eq(cx: &mut ExtCtxt, span: Span, diff --git a/src/libsyntax_ext/deriving/cmp/partial_ord.rs b/src/libsyntax_ext/deriving/cmp/partial_ord.rs index cfc6dbe5cd0..26c14ae934f 100644 --- a/src/libsyntax_ext/deriving/cmp/partial_ord.rs +++ b/src/libsyntax_ext/deriving/cmp/partial_ord.rs @@ -14,11 +14,11 @@ use deriving::generic::*; use deriving::generic::ty::*; use syntax::ast::{MetaItem, Expr, BinOpKind, self}; -use syntax::codemap::Span; use syntax::ext::base::{ExtCtxt, Annotatable}; use syntax::ext::build::AstBuilder; use syntax::parse::token::InternedString; use syntax::ptr::P; +use syntax_pos::Span; pub fn expand_deriving_partial_ord(cx: &mut ExtCtxt, span: Span, diff --git a/src/libsyntax_ext/deriving/debug.rs b/src/libsyntax_ext/deriving/debug.rs index d86eae820a8..34c872bef11 100644 --- a/src/libsyntax_ext/deriving/debug.rs +++ b/src/libsyntax_ext/deriving/debug.rs @@ -13,11 +13,11 @@ use deriving::generic::ty::*; use syntax::ast; use syntax::ast::{MetaItem, Expr}; -use syntax::codemap::{Span, respan, DUMMY_SP}; use syntax::ext::base::{ExtCtxt, Annotatable}; use syntax::ext::build::AstBuilder; use syntax::parse::token; use syntax::ptr::P; +use syntax_pos::{Span, DUMMY_SP}; pub fn expand_deriving_debug(cx: &mut ExtCtxt, span: Span, @@ -78,7 +78,7 @@ fn show_substructure(cx: &mut ExtCtxt, span: Span, let fmt = substr.nonself_args[0].clone(); - let stmts = match *substr.fields { + let mut stmts = match *substr.fields { Struct(_, ref fields) | EnumMatching(_, _, ref fields) => { let mut stmts = vec![]; if !is_struct { @@ -136,7 +136,8 @@ fn show_substructure(cx: &mut ExtCtxt, span: Span, token::str_to_ident("finish"), vec![]); - let block = cx.block(span, stmts, Some(expr)); + stmts.push(cx.stmt_expr(expr)); + let block = cx.block(span, stmts); cx.expr_block(block) } @@ -149,8 +150,11 @@ fn stmt_let_undescore(cx: &mut ExtCtxt, init: Some(expr), id: ast::DUMMY_NODE_ID, span: sp, - attrs: None, + attrs: ast::ThinVec::new(), }); - let decl = respan(sp, ast::DeclKind::Local(local)); - respan(sp, ast::StmtKind::Decl(P(decl), ast::DUMMY_NODE_ID)) + ast::Stmt { + id: ast::DUMMY_NODE_ID, + node: ast::StmtKind::Local(local), + span: sp, + } } diff --git a/src/libsyntax_ext/deriving/decodable.rs b/src/libsyntax_ext/deriving/decodable.rs index 04888d046ad..488402c48f7 100644 --- a/src/libsyntax_ext/deriving/decodable.rs +++ b/src/libsyntax_ext/deriving/decodable.rs @@ -16,12 +16,12 @@ use deriving::generic::ty::*; use syntax::ast; use syntax::ast::{MetaItem, Expr, Mutability}; -use syntax::codemap::Span; use syntax::ext::base::{ExtCtxt, Annotatable}; use syntax::ext::build::AstBuilder; use syntax::parse::token::InternedString; use syntax::parse::token; use syntax::ptr::P; +use syntax_pos::Span; pub fn expand_deriving_rustc_decodable(cx: &mut ExtCtxt, span: Span, diff --git a/src/libsyntax_ext/deriving/default.rs b/src/libsyntax_ext/deriving/default.rs index a6a4830fab7..2711ccba819 100644 --- a/src/libsyntax_ext/deriving/default.rs +++ b/src/libsyntax_ext/deriving/default.rs @@ -12,11 +12,11 @@ use deriving::generic::*; use deriving::generic::ty::*; use syntax::ast::{MetaItem, Expr}; -use syntax::codemap::Span; use syntax::ext::base::{ExtCtxt, Annotatable}; use syntax::ext::build::AstBuilder; use syntax::parse::token::InternedString; use syntax::ptr::P; +use syntax_pos::Span; pub fn expand_deriving_default(cx: &mut ExtCtxt, span: Span, diff --git a/src/libsyntax_ext/deriving/encodable.rs b/src/libsyntax_ext/deriving/encodable.rs index 66672305829..ad378621247 100644 --- a/src/libsyntax_ext/deriving/encodable.rs +++ b/src/libsyntax_ext/deriving/encodable.rs @@ -93,11 +93,11 @@ use deriving::generic::*; use deriving::generic::ty::*; use syntax::ast::{MetaItem, Expr, ExprKind, Mutability}; -use syntax::codemap::Span; use syntax::ext::base::{ExtCtxt,Annotatable}; use syntax::ext::build::AstBuilder; use syntax::parse::token; use syntax::ptr::P; +use syntax_pos::Span; pub fn expand_deriving_rustc_encodable(cx: &mut ExtCtxt, span: Span, @@ -285,7 +285,7 @@ fn encodable_substructure(cx: &mut ExtCtxt, trait_span: Span, cx.expr_str(trait_span, substr.type_ident.name.as_str()), blk )); - cx.expr_block(cx.block(trait_span, vec!(me), Some(ret))) + cx.expr_block(cx.block(trait_span, vec![me, cx.stmt_expr(ret)])) } _ => cx.bug("expected Struct or EnumMatching in derive(Encodable)") diff --git a/src/libsyntax_ext/deriving/generic/mod.rs b/src/libsyntax_ext/deriving/generic/mod.rs index d6adec84e84..647e414a7fd 100644 --- a/src/libsyntax_ext/deriving/generic/mod.rs +++ b/src/libsyntax_ext/deriving/generic/mod.rs @@ -197,12 +197,12 @@ use syntax::attr; use syntax::attr::AttrMetaMethods; use syntax::ext::base::{ExtCtxt, Annotatable}; use syntax::ext::build::AstBuilder; -use syntax::codemap::{self, respan, DUMMY_SP}; -use syntax::codemap::Span; -use syntax::errors::Handler; +use syntax::codemap::{self, respan}; use syntax::util::move_map::MoveMap; use syntax::parse::token::{keywords, InternedString}; use syntax::ptr::P; +use syntax_pos::{Span, DUMMY_SP}; +use errors::Handler; use self::ty::{LifetimeBounds, Path, Ptr, PtrTy, Self_, Ty}; @@ -353,8 +353,8 @@ fn find_type_parameters(ty: &ast::Ty, ty_param_names: &[ast::Name]) -> Vec<P<ast types: Vec<P<ast::Ty>>, } - impl<'a> visit::Visitor<'a> for Visitor<'a> { - fn visit_ty(&mut self, ty: &'a ast::Ty) { + impl<'a> visit::Visitor for Visitor<'a> { + fn visit_ty(&mut self, ty: &ast::Ty) { match ty.node { ast::TyKind::Path(_, ref path) if !path.global => { match path.segments.first() { @@ -1332,8 +1332,8 @@ impl<'a> MethodDef<'a> { // } let all_match = cx.expr_match(sp, match_arg, match_arms); let arm_expr = cx.expr_if(sp, discriminant_test, all_match, Some(arm_expr)); - cx.expr_block( - cx.block_all(sp, index_let_stmts, Some(arm_expr))) + index_let_stmts.push(cx.stmt_expr(arm_expr)); + cx.expr_block(cx.block(sp, index_let_stmts)) } else if variants.is_empty() { // As an additional wrinkle, For a zero-variant enum A, // currently the compiler diff --git a/src/libsyntax_ext/deriving/generic/ty.rs b/src/libsyntax_ext/deriving/generic/ty.rs index b581f5267ea..626fbaada5c 100644 --- a/src/libsyntax_ext/deriving/generic/ty.rs +++ b/src/libsyntax_ext/deriving/generic/ty.rs @@ -18,8 +18,9 @@ use syntax::ast; use syntax::ast::{Expr, Generics, Ident, SelfKind}; use syntax::ext::base::ExtCtxt; use syntax::ext::build::AstBuilder; -use syntax::codemap::{Span,respan}; +use syntax::codemap::respan; use syntax::ptr::P; +use syntax_pos::Span; /// The types of pointers #[derive(Clone, Eq, PartialEq)] diff --git a/src/libsyntax_ext/deriving/hash.rs b/src/libsyntax_ext/deriving/hash.rs index fd449372cb3..0fad96c84ef 100644 --- a/src/libsyntax_ext/deriving/hash.rs +++ b/src/libsyntax_ext/deriving/hash.rs @@ -13,10 +13,10 @@ use deriving::generic::*; use deriving::generic::ty::*; use syntax::ast::{MetaItem, Expr, Mutability}; -use syntax::codemap::Span; use syntax::ext::base::{ExtCtxt, Annotatable}; use syntax::ext::build::AstBuilder; use syntax::ptr::P; +use syntax_pos::Span; pub fn expand_deriving_hash(cx: &mut ExtCtxt, span: Span, @@ -99,5 +99,5 @@ fn hash_substructure(cx: &mut ExtCtxt, trait_span: Span, substr: &Substructure) stmts.push(call_hash(span, self_.clone())); } - cx.expr_block(cx.block(trait_span, stmts, None)) + cx.expr_block(cx.block(trait_span, stmts)) } diff --git a/src/libsyntax_ext/deriving/mod.rs b/src/libsyntax_ext/deriving/mod.rs index 6fb6dee94ed..169e8073661 100644 --- a/src/libsyntax_ext/deriving/mod.rs +++ b/src/libsyntax_ext/deriving/mod.rs @@ -16,9 +16,10 @@ use syntax::ext::base::{ExtCtxt, SyntaxEnv, Annotatable}; use syntax::ext::base::{MultiDecorator, MultiItemDecorator, MultiModifier}; use syntax::ext::build::AstBuilder; use syntax::feature_gate; -use syntax::codemap::{self, Span}; +use syntax::codemap; use syntax::parse::token::{intern, intern_and_get_ident}; use syntax::ptr::P; +use syntax_pos::Span; macro_rules! pathvec { ($($x:ident)::+) => ( @@ -297,8 +298,7 @@ fn call_intrinsic(cx: &ExtCtxt, let call = cx.expr_call_global(span, path, args); cx.expr_block(P(ast::Block { - stmts: vec![], - expr: Some(call), + stmts: vec![cx.stmt_expr(call)], id: ast::DUMMY_NODE_ID, rules: ast::BlockCheckMode::Unsafe(ast::CompilerGenerated), span: span })) diff --git a/src/libsyntax_ext/env.rs b/src/libsyntax_ext/env.rs index 63ec9cac073..546f8eaa692 100644 --- a/src/libsyntax_ext/env.rs +++ b/src/libsyntax_ext/env.rs @@ -15,15 +15,16 @@ */ use syntax::ast; -use syntax::codemap::Span; use syntax::ext::base::*; use syntax::ext::base; use syntax::ext::build::AstBuilder; use syntax::parse::token; +use syntax_pos::Span; +use syntax::tokenstream; use std::env; -pub fn expand_option_env<'cx>(cx: &'cx mut ExtCtxt, sp: Span, tts: &[ast::TokenTree]) +pub fn expand_option_env<'cx>(cx: &'cx mut ExtCtxt, sp: Span, tts: &[tokenstream::TokenTree]) -> Box<base::MacResult+'cx> { let var = match get_single_str_from_tts(cx, sp, tts, "option_env!") { None => return DummyResult::expr(sp), @@ -56,7 +57,7 @@ pub fn expand_option_env<'cx>(cx: &'cx mut ExtCtxt, sp: Span, tts: &[ast::TokenT MacEager::expr(e) } -pub fn expand_env<'cx>(cx: &'cx mut ExtCtxt, sp: Span, tts: &[ast::TokenTree]) +pub fn expand_env<'cx>(cx: &'cx mut ExtCtxt, sp: Span, tts: &[tokenstream::TokenTree]) -> Box<base::MacResult+'cx> { let mut exprs = match get_exprs_from_tts(cx, sp, tts) { Some(ref exprs) if exprs.is_empty() => { diff --git a/src/libsyntax_ext/format.rs b/src/libsyntax_ext/format.rs index abfa6558064..f311f16f11b 100644 --- a/src/libsyntax_ext/format.rs +++ b/src/libsyntax_ext/format.rs @@ -14,13 +14,14 @@ use self::Position::*; use fmt_macros as parse; use syntax::ast; -use syntax::codemap::{Span, respan, DUMMY_SP}; use syntax::ext::base::*; use syntax::ext::base; use syntax::ext::build::AstBuilder; use syntax::fold::Folder; use syntax::parse::token::{self, keywords}; use syntax::ptr::P; +use syntax_pos::{Span, DUMMY_SP}; +use syntax::tokenstream; use std::collections::HashMap; @@ -80,7 +81,7 @@ struct Context<'a, 'b:'a> { /// Some((fmtstr, unnamed arguments, ordering of named arguments, /// named arguments)) /// ``` -fn parse_args(ecx: &mut ExtCtxt, sp: Span, tts: &[ast::TokenTree]) +fn parse_args(ecx: &mut ExtCtxt, sp: Span, tts: &[tokenstream::TokenTree]) -> Option<(P<ast::Expr>, Vec<P<ast::Expr>>, Vec<String>, HashMap<String, P<ast::Expr>>)> { let mut args = Vec::new(); @@ -441,12 +442,14 @@ impl<'a, 'b> Context<'a, 'b> { let name = ecx.ident_of(name); let item = ecx.item(sp, name, vec![], st); - let decl = respan(sp, ast::DeclKind::Item(item)); + let stmt = ast::Stmt { + id: ast::DUMMY_NODE_ID, + node: ast::StmtKind::Item(item), + span: sp, + }; // Wrap the declaration in a block so that it forms a single expression. - ecx.expr_block(ecx.block(sp, - vec![respan(sp, ast::StmtKind::Decl(P(decl), ast::DUMMY_NODE_ID))], - Some(ecx.expr_ident(sp, name)))) + ecx.expr_block(ecx.block(sp, vec![stmt, ecx.stmt_expr(ecx.expr_ident(sp, name))])) } /// Actually builds the expression which the iformat! block will be expanded @@ -606,7 +609,7 @@ impl<'a, 'b> Context<'a, 'b> { } pub fn expand_format_args<'cx>(ecx: &'cx mut ExtCtxt, sp: Span, - tts: &[ast::TokenTree]) + tts: &[tokenstream::TokenTree]) -> Box<base::MacResult+'cx> { match parse_args(ecx, sp, tts) { diff --git a/src/libsyntax_ext/lib.rs b/src/libsyntax_ext/lib.rs index 8f5362b4d28..17b200bac58 100644 --- a/src/libsyntax_ext/lib.rs +++ b/src/libsyntax_ext/lib.rs @@ -26,6 +26,8 @@ extern crate fmt_macros; #[macro_use] extern crate log; #[macro_use] extern crate syntax; +extern crate syntax_pos; +extern crate rustc_errors as errors; use syntax::ext::base::{MacroExpanderFn, NormalTT}; use syntax::ext::base::{SyntaxEnv, SyntaxExtension}; diff --git a/src/libsyntax_ext/log_syntax.rs b/src/libsyntax_ext/log_syntax.rs index ee944abb645..9645c5bb427 100644 --- a/src/libsyntax_ext/log_syntax.rs +++ b/src/libsyntax_ext/log_syntax.rs @@ -8,15 +8,15 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use syntax::ast; -use syntax::codemap; use syntax::ext::base; use syntax::feature_gate; use syntax::print; +use syntax::tokenstream; +use syntax_pos; pub fn expand_syntax_ext<'cx>(cx: &'cx mut base::ExtCtxt, - sp: codemap::Span, - tts: &[ast::TokenTree]) + sp: syntax_pos::Span, + tts: &[tokenstream::TokenTree]) -> Box<base::MacResult+'cx> { if !cx.ecfg.enable_log_syntax() { feature_gate::emit_feature_err(&cx.parse_sess.span_diagnostic, diff --git a/src/libsyntax_ext/trace_macros.rs b/src/libsyntax_ext/trace_macros.rs index 7b1e985442a..ad396d38de9 100644 --- a/src/libsyntax_ext/trace_macros.rs +++ b/src/libsyntax_ext/trace_macros.rs @@ -8,13 +8,12 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use syntax::ast::TokenTree; -use syntax::codemap::Span; use syntax::ext::base::ExtCtxt; use syntax::ext::base; use syntax::feature_gate; use syntax::parse::token::keywords; - +use syntax_pos::Span; +use syntax::tokenstream::TokenTree; pub fn expand_trace_macros(cx: &mut ExtCtxt, sp: Span, |
