]> git.lizzy.rs Git - rust.git/commitdiff
fixed a bug that caused double-expand-traversal of macros that expand into modules.
authorJohn Clements <clements@racket-lang.org>
Fri, 26 Jul 2013 16:57:30 +0000 (12:57 -0400)
committerJohn Clements <clements@racket-lang.org>
Fri, 6 Sep 2013 20:35:13 +0000 (13:35 -0700)
src/libsyntax/ext/expand.rs

index ad07d166f4545415ec7540367e4202c669137d5a..ad1420f35cd206e11cd6185a253e20f19e7049c6 100644 (file)
@@ -342,25 +342,16 @@ pub fn expand_item(extsbox: @mut SyntaxEnv,
                    fld: @ast_fold,
                    orig: @fn(@ast::item, @ast_fold) -> Option<@ast::item>)
                 -> Option<@ast::item> {
-    // need to do expansion first... it might turn out to be a module.
-    let maybe_it = match it.node {
-      ast::item_mac(*) => expand_item_mac(extsbox, cx, it, fld),
-      _ => Some(it)
-    };
-    match maybe_it {
-      Some(it) => {
-          match it.node {
-              ast::item_mod(_) | ast::item_foreign_mod(_) => {
-                  cx.mod_push(it.ident);
-                  let macro_escape = contains_macro_escape(it.attrs);
-                  let result = with_exts_frame!(extsbox,macro_escape,orig(it,fld));
-                  cx.mod_pop();
-                  result
-              }
-              _ => orig(it,fld)
-          }
-      }
-      None => None
+    match it.node {
+        ast::item_mac(*) => expand_item_mac(extsbox, cx, it, fld),
+        ast::item_mod(_) | ast::item_foreign_mod(_) => {
+            cx.mod_push(it.ident);
+            let macro_escape = contains_macro_escape(it.attrs);
+            let result = with_exts_frame!(extsbox,macro_escape,orig(it,fld));
+            cx.mod_pop();
+            result
+        },
+        _ => orig(it,fld)
     }
 }