diff --git a/src/librustc/front/test.rs b/src/librustc/front/test.rs index 41c70c4c5b417..c1bf578163ab2 100644 --- a/src/librustc/front/test.rs +++ b/src/librustc/front/test.rs @@ -17,7 +17,7 @@ use front::config; use std::vec; use syntax::ast_util::*; use syntax::attr; -use syntax::codemap::{dummy_sp, span, ExpandedFrom, CallInfo, NameAndSpan}; +use syntax::codemap::{dummy_sp, span, ExpnInfo, NameAndSpan}; use syntax::codemap; use syntax::ext::base::ExtCtxt; use syntax::fold; @@ -72,13 +72,13 @@ fn generate_test_harness(sess: session::Session, }; let ext_cx = cx.ext_cx; - ext_cx.bt_push(ExpandedFrom(CallInfo { + ext_cx.bt_push(ExpnInfo { call_site: dummy_sp(), callee: NameAndSpan { name: @"test", span: None } - })); + }); let precursor = @fold::AstFoldFns { fold_crate: fold::wrap(|a,b| fold_crate(cx, a, b) ), diff --git a/src/libsyntax/codemap.rs b/src/libsyntax/codemap.rs index bcf617c56ae1e..7e89d04078160 100644 --- a/src/libsyntax/codemap.rs +++ b/src/libsyntax/codemap.rs @@ -174,18 +174,13 @@ pub struct FileMapAndBytePos {fm: @FileMap, pos: BytePos} #[deriving(IterBytes)] pub struct NameAndSpan {name: @str, span: Option} +/// Extra information for tracking macro expansion of spans #[deriving(IterBytes)] -pub struct CallInfo { +pub struct ExpnInfo { call_site: span, callee: NameAndSpan } -/// Extra information for tracking macro expansion of spans -#[deriving(IterBytes)] -pub enum ExpnInfo { - ExpandedFrom(CallInfo) -} - pub type FileName = @str; pub struct FileLines diff --git a/src/libsyntax/ext/base.rs b/src/libsyntax/ext/base.rs index 78fdb99753d40..ad14b567b9602 100644 --- a/src/libsyntax/ext/base.rs +++ b/src/libsyntax/ext/base.rs @@ -11,8 +11,7 @@ use ast; use ast::Name; use codemap; -use codemap::{CodeMap, span, ExpnInfo, ExpandedFrom}; -use codemap::CallInfo; +use codemap::{CodeMap, span, ExpnInfo}; use diagnostic::span_handler; use ext; use parse; @@ -243,7 +242,7 @@ impl ExtCtxt { pub fn cfg(&self) -> ast::crate_cfg { copy self.cfg } pub fn call_site(&self) -> span { match *self.backtrace { - Some(@ExpandedFrom(CallInfo {call_site: cs, _})) => cs, + Some(@ExpnInfo {call_site: cs, _}) => cs, None => self.bug("missing top span") } } @@ -254,21 +253,19 @@ impl ExtCtxt { pub fn mod_path(&self) -> ~[ast::ident] { copy *self.mod_path } pub fn bt_push(&self, ei: codemap::ExpnInfo) { match ei { - ExpandedFrom(CallInfo {call_site: cs, callee: ref callee}) => { + ExpnInfo {call_site: cs, callee: ref callee} => { *self.backtrace = - Some(@ExpandedFrom(CallInfo { + Some(@ExpnInfo { call_site: span {lo: cs.lo, hi: cs.hi, expn_info: *self.backtrace}, - callee: copy *callee})); + callee: copy *callee}); } } } pub fn bt_pop(&self) { match *self.backtrace { - Some(@ExpandedFrom( - CallInfo { - call_site: span {expn_info: prev, _}, _ - })) => { + Some(@ExpnInfo { + call_site: span {expn_info: prev, _}, _}) => { *self.backtrace = prev } _ => self.bug("tried to pop without a push") diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs index 15f915ba4d8da..32dd112cad061 100644 --- a/src/libsyntax/ext/expand.rs +++ b/src/libsyntax/ext/expand.rs @@ -16,7 +16,7 @@ use ast; use ast_util::{new_rename, new_mark, resolve}; use attr; use codemap; -use codemap::{span, CallInfo, ExpandedFrom, NameAndSpan, spanned}; +use codemap::{span, ExpnInfo, NameAndSpan, spanned}; use ext::base::*; use fold::*; use parse; @@ -60,13 +60,13 @@ pub fn expand_expr(extsbox: @mut SyntaxEnv, expander: exp, span: exp_sp }))) => { - cx.bt_push(ExpandedFrom(CallInfo { + cx.bt_push(ExpnInfo { call_site: s, callee: NameAndSpan { name: extnamestr, span: exp_sp, }, - })); + }); let expanded = match exp(cx, mac.span, *tts) { MRExpr(e) => e, @@ -131,13 +131,13 @@ pub fn expand_mod_items(extsbox: @mut SyntaxEnv, match (*extsbox).find(&intern(mname)) { Some(@SE(ItemDecorator(dec_fn))) => { - cx.bt_push(ExpandedFrom(CallInfo { + cx.bt_push(ExpnInfo { call_site: attr.span, callee: NameAndSpan { name: mname, span: None } - })); + }); let r = dec_fn(cx, attr.span, attr.node.value, items); cx.bt_pop(); r @@ -227,13 +227,13 @@ pub fn expand_item_mac(extsbox: @mut SyntaxEnv, given '%s'", extnamestr, ident_to_str(&it.ident))); } - cx.bt_push(ExpandedFrom(CallInfo { + cx.bt_push(ExpnInfo { call_site: it.span, callee: NameAndSpan { name: extnamestr, span: expand.span } - })); + }); ((*expand).expander)(cx, it.span, tts) } Some(@SE(IdentTT(ref expand))) => { @@ -242,13 +242,13 @@ pub fn expand_item_mac(extsbox: @mut SyntaxEnv, fmt!("macro %s! expects an ident argument", extnamestr)); } - cx.bt_push(ExpandedFrom(CallInfo { + cx.bt_push(ExpnInfo { call_site: it.span, callee: NameAndSpan { name: extnamestr, span: expand.span } - })); + }); ((*expand).expander)(cx, it.span, it.ident, tts) } _ => cx.span_fatal( @@ -319,10 +319,10 @@ pub fn expand_stmt(extsbox: @mut SyntaxEnv, Some(@SE(NormalTT( SyntaxExpanderTT{expander: exp, span: exp_sp}))) => { - cx.bt_push(ExpandedFrom(CallInfo { + cx.bt_push(ExpnInfo { call_site: sp, callee: NameAndSpan { name: extnamestr, span: exp_sp } - })); + }); let expanded = match exp(cx, mac.span, tts) { MRExpr(e) => @codemap::spanned { node: stmt_expr(e, cx.next_id()), diff --git a/src/libsyntax/ext/source_util.rs b/src/libsyntax/ext/source_util.rs index f6325c2eb2c12..b43536389e2cd 100644 --- a/src/libsyntax/ext/source_util.rs +++ b/src/libsyntax/ext/source_util.rs @@ -10,8 +10,8 @@ use ast; use codemap; -use codemap::{Pos, ExpandedFrom, span}; -use codemap::{CallInfo, NameAndSpan}; +use codemap::{Pos, span}; +use codemap::{ExpnInfo, NameAndSpan}; use ext::base::*; use ext::base; use ext::build::AstBuilder; @@ -117,14 +117,14 @@ pub fn expand_include_bin(cx: @ExtCtxt, sp: span, tts: &[ast::token_tree]) // recur along an ExpnInfo chain to find the original expression fn topmost_expn_info(expn_info: @codemap::ExpnInfo) -> @codemap::ExpnInfo { match *expn_info { - ExpandedFrom(CallInfo { call_site: ref call_site, _ }) => { + ExpnInfo { call_site: ref call_site, _ } => { match call_site.expn_info { Some(next_expn_info) => { match *next_expn_info { - ExpandedFrom(CallInfo { + ExpnInfo { callee: NameAndSpan { name: ref name, _ }, _ - }) => { + } => { // Don't recurse into file using "include!" if "include" == *name { expn_info