summary refs log tree commit diff
path: root/src/libsyntax/ext
diff options
context:
space:
mode:
authorManish Goregaokar <manishsmail@gmail.com>2015-08-27 05:16:05 +0530
committerManish Goregaokar <manishsmail@gmail.com>2015-08-27 05:16:05 +0530
commit4ec7b713dd2de43f4b0b03d33271f9c7dbb56d1c (patch)
treef4573efc079c86e78860263e99dcc17e5ba414d0 /src/libsyntax/ext
parent5c630a61c658cb7d861a60da6951ee06619337b2 (diff)
downloadrust-4ec7b713dd2de43f4b0b03d33271f9c7dbb56d1c.tar.gz
rust-4ec7b713dd2de43f4b0b03d33271f9c7dbb56d1c.zip
Enumify CompilerExpansion in ExpnInfo
Diffstat (limited to 'src/libsyntax/ext')
-rw-r--r--src/libsyntax/ext/asm.rs3
-rw-r--r--src/libsyntax/ext/base.rs9
-rw-r--r--src/libsyntax/ext/deriving/generic/mod.rs3
-rw-r--r--src/libsyntax/ext/expand.rs48
4 files changed, 27 insertions, 36 deletions
diff --git a/src/libsyntax/ext/asm.rs b/src/libsyntax/ext/asm.rs
index 69159690328..2509a071807 100644
--- a/src/libsyntax/ext/asm.rs
+++ b/src/libsyntax/ext/asm.rs
@@ -211,8 +211,7 @@ pub fn expand_asm<'cx>(cx: &'cx mut ExtCtxt, sp: Span, tts: &[ast::TokenTree])
     let expn_id = cx.codemap().record_expansion(codemap::ExpnInfo {
         call_site: sp,
         callee: codemap::NameAndSpan {
-            name: "asm".to_string(),
-            format: codemap::MacroBang,
+            format: codemap::MacroBang("asm".to_string()),
             span: None,
             allow_internal_unstable: false,
         },
diff --git a/src/libsyntax/ext/base.rs b/src/libsyntax/ext/base.rs
index ef11a2bd66e..ef49ef11497 100644
--- a/src/libsyntax/ext/base.rs
+++ b/src/libsyntax/ext/base.rs
@@ -714,13 +714,14 @@ impl<'a> ExtCtxt<'a> {
         loop {
             if self.codemap().with_expn_info(expn_id, |info| {
                 info.map_or(None, |i| {
-                    if i.callee.name == "include" {
+                    if i.callee.name() == "include" {
                         // Stop going up the backtrace once include! is encountered
                         return None;
                     }
                     expn_id = i.call_site.expn_id;
-                    if i.callee.format != CompilerExpansion {
-                        last_macro = Some(i.call_site)
+                    match i.callee.format {
+                        CompilerExpansion(..) => (),
+                        _ => last_macro = Some(i.call_site),
                     }
                     return Some(());
                 })
@@ -744,7 +745,7 @@ impl<'a> ExtCtxt<'a> {
         if self.recursion_count > self.ecfg.recursion_limit {
             panic!(self.span_fatal(ei.call_site,
                             &format!("recursion limit reached while expanding the macro `{}`",
-                                    ei.callee.name)));
+                                    ei.callee.name())));
         }
 
         let mut call_site = ei.call_site;
diff --git a/src/libsyntax/ext/deriving/generic/mod.rs b/src/libsyntax/ext/deriving/generic/mod.rs
index 2986e968045..f23dec92f93 100644
--- a/src/libsyntax/ext/deriving/generic/mod.rs
+++ b/src/libsyntax/ext/deriving/generic/mod.rs
@@ -1436,8 +1436,7 @@ impl<'a> TraitDef<'a> {
         to_set.expn_id = cx.codemap().record_expansion(codemap::ExpnInfo {
             call_site: to_set,
             callee: codemap::NameAndSpan {
-                name: format!("derive({})", trait_name),
-                format: codemap::MacroAttribute,
+                format: codemap::MacroAttribute(format!("derive({})", trait_name)),
                 span: Some(self.span),
                 allow_internal_unstable: false,
             }
diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs
index 4f89b3494d4..bf995c00009 100644
--- a/src/libsyntax/ext/expand.rs
+++ b/src/libsyntax/ext/expand.rs
@@ -19,7 +19,8 @@ use ext::build::AstBuilder;
 use attr;
 use attr::AttrMetaMethods;
 use codemap;
-use codemap::{Span, Spanned, ExpnInfo, NameAndSpan, MacroBang, MacroAttribute, CompilerExpansion};
+use codemap::{Span, Spanned, ExpnInfo, NameAndSpan, MacroBang, MacroAttribute};
+use codemap::{CompilerExpansion, CompilerExpansionFormat};
 use ext::base::*;
 use feature_gate::{self, Features, GatedCfg};
 use fold;
@@ -43,12 +44,12 @@ fn mk_core_path(fld: &mut MacroExpander,
 }
 
 pub fn expand_expr(e: P<ast::Expr>, fld: &mut MacroExpander) -> P<ast::Expr> {
-    fn push_compiler_expansion(fld: &mut MacroExpander, span: Span, expansion_desc: &str) {
+    fn push_compiler_expansion(fld: &mut MacroExpander, span: Span,
+                               expansion_type: CompilerExpansionFormat) {
         fld.cx.bt_push(ExpnInfo {
             call_site: span,
             callee: NameAndSpan {
-                name: expansion_desc.to_string(),
-                format: CompilerExpansion,
+                format: CompilerExpansion(expansion_type),
 
                 // This does *not* mean code generated after
                 // `push_compiler_expansion` is automatically exempt
@@ -111,7 +112,7 @@ pub fn expand_expr(e: P<ast::Expr>, fld: &mut MacroExpander) -> P<ast::Expr> {
                 &fld.cx.parse_sess.span_diagnostic,
                 expr_span);
 
-            push_compiler_expansion(fld, expr_span, "placement-in expansion");
+            push_compiler_expansion(fld, expr_span, CompilerExpansionFormat::PlacementIn);
 
             let value_span = value_expr.span;
             let placer_span = placer.span;
@@ -223,7 +224,7 @@ pub fn expand_expr(e: P<ast::Expr>, fld: &mut MacroExpander) -> P<ast::Expr> {
             //     }
             //   }
 
-            push_compiler_expansion(fld, span, "while let expansion");
+            push_compiler_expansion(fld, span, CompilerExpansionFormat::WhileLet);
 
             // `<pat> => <body>`
             let pat_arm = {
@@ -262,7 +263,7 @@ pub fn expand_expr(e: P<ast::Expr>, fld: &mut MacroExpander) -> P<ast::Expr> {
             //     _ => [<elseopt> | ()]
             //   }
 
-            push_compiler_expansion(fld, span, "if let expansion");
+            push_compiler_expansion(fld, span, CompilerExpansionFormat::IfLet);
 
             // `<pat> => <body>`
             let pat_arm = {
@@ -334,7 +335,7 @@ pub fn expand_expr(e: P<ast::Expr>, fld: &mut MacroExpander) -> P<ast::Expr> {
         ast::ExprIf(cond, blk, elseopt) => {
             let elseopt = elseopt.map(|els| els.and_then(|els| match els.node {
                 ast::ExprIfLet(..) => {
-                    push_compiler_expansion(fld, span, "if let expansion");
+                    push_compiler_expansion(fld, span, CompilerExpansionFormat::IfLet);
                     // wrap the if-let expr in a block
                     let span = els.span;
                     let blk = P(ast::Block {
@@ -378,7 +379,7 @@ pub fn expand_expr(e: P<ast::Expr>, fld: &mut MacroExpander) -> P<ast::Expr> {
             //     result
             //   }
 
-            push_compiler_expansion(fld, span, "for loop expansion");
+            push_compiler_expansion(fld, span, CompilerExpansionFormat::ForLoop);
 
             let span = fld.new_span(span);
 
@@ -458,7 +459,7 @@ pub fn expand_expr(e: P<ast::Expr>, fld: &mut MacroExpander) -> P<ast::Expr> {
         }
 
         ast::ExprClosure(capture_clause, fn_decl, block) => {
-            push_compiler_expansion(fld, span, "closure expansion");
+            push_compiler_expansion(fld, span, CompilerExpansionFormat::Closure);
             let (rewritten_fn_decl, rewritten_block)
                 = expand_and_rename_fn_decl_and_block(fn_decl, block, fld);
             let new_node = ast::ExprClosure(capture_clause,
@@ -542,8 +543,7 @@ fn expand_mac_invoc<T, F, G>(mac: ast::Mac,
                         fld.cx.bt_push(ExpnInfo {
                                 call_site: span,
                                 callee: NameAndSpan {
-                                    name: extname.to_string(),
-                                    format: MacroBang,
+                                    format: MacroBang(extname.to_string()),
                                     span: exp_span,
                                     allow_internal_unstable: allow_internal_unstable,
                                 },
@@ -721,8 +721,7 @@ pub fn expand_item_mac(it: P<ast::Item>,
                     fld.cx.bt_push(ExpnInfo {
                         call_site: it.span,
                         callee: NameAndSpan {
-                            name: extname.to_string(),
-                            format: MacroBang,
+                            format: MacroBang(extname.to_string()),
                             span: span,
                             allow_internal_unstable: allow_internal_unstable,
                         }
@@ -741,8 +740,7 @@ pub fn expand_item_mac(it: P<ast::Item>,
                     fld.cx.bt_push(ExpnInfo {
                         call_site: it.span,
                         callee: NameAndSpan {
-                            name: extname.to_string(),
-                            format: MacroBang,
+                            format: MacroBang(extname.to_string()),
                             span: span,
                             allow_internal_unstable: allow_internal_unstable,
                         }
@@ -762,8 +760,7 @@ pub fn expand_item_mac(it: P<ast::Item>,
                     fld.cx.bt_push(ExpnInfo {
                         call_site: it.span,
                         callee: NameAndSpan {
-                            name: extname.to_string(),
-                            format: MacroBang,
+                            format: MacroBang(extname.to_string()),
                             span: None,
                             // `macro_rules!` doesn't directly allow
                             // unstable (this is orthogonal to whether
@@ -1090,8 +1087,7 @@ fn expand_pat(p: P<ast::Pat>, fld: &mut MacroExpander) -> P<ast::Pat> {
                     fld.cx.bt_push(ExpnInfo {
                         call_site: span,
                         callee: NameAndSpan {
-                            name: extname.to_string(),
-                            format: MacroBang,
+                            format: MacroBang(extname.to_string()),
                             span: tt_span,
                             allow_internal_unstable: allow_internal_unstable,
                         }
@@ -1302,8 +1298,7 @@ fn expand_decorators(a: Annotatable,
                     fld.cx.bt_push(ExpnInfo {
                         call_site: attr.span,
                         callee: NameAndSpan {
-                            name: mname.to_string(),
-                            format: MacroAttribute,
+                            format: MacroAttribute(mname.to_string()),
                             span: Some(attr.span),
                             // attributes can do whatever they like,
                             // for now.
@@ -1330,8 +1325,7 @@ fn expand_decorators(a: Annotatable,
                     fld.cx.bt_push(ExpnInfo {
                         call_site: attr.span,
                         callee: NameAndSpan {
-                            name: mname.to_string(),
-                            format: MacroAttribute,
+                            format: MacroAttribute(mname.to_string()),
                             span: Some(attr.span),
                             // attributes can do whatever they like,
                             // for now.
@@ -1381,8 +1375,7 @@ fn expand_item_multi_modifier(mut it: Annotatable,
                     fld.cx.bt_push(ExpnInfo {
                         call_site: attr.span,
                         callee: NameAndSpan {
-                            name: mname.to_string(),
-                            format: MacroAttribute,
+                            format: MacroAttribute(mname.to_string()),
                             span: Some(attr.span),
                             // attributes can do whatever they like,
                             // for now
@@ -1430,8 +1423,7 @@ fn expand_item_modifiers(mut it: P<ast::Item>,
                     fld.cx.bt_push(ExpnInfo {
                         call_site: attr.span,
                         callee: NameAndSpan {
-                            name: mname.to_string(),
-                            format: MacroAttribute,
+                            format: MacroAttribute(mname.to_string()),
                             span: Some(attr.span),
                             // attributes can do whatever they like,
                             // for now