]> git.lizzy.rs Git - rust.git/commitdiff
test case for expansion of method macro
authorJohn Clements <clements@racket-lang.org>
Mon, 7 Jul 2014 22:12:31 +0000 (15:12 -0700)
committerJohn Clements <clements@racket-lang.org>
Tue, 8 Jul 2014 23:27:34 +0000 (16:27 -0700)
src/libsyntax/ext/expand.rs

index 709db52262d4bc344206765d11002d2a2a8d8279..47c86f1c9f5c2f487e962f5f5240ba25677129c3 100644 (file)
@@ -512,8 +512,10 @@ fn expand_item_mac(it: Gc<ast::Item>, fld: &mut MacroExpander)
 
     let items = match expanded.make_def() {
         Some(MacroDef { name, ext }) => {
-            // yikes... no idea how to apply the mark to this. I'm afraid
-            // we're going to have to wait-and-see on this one.
+            // hidden invariant: this should only be possible as the
+            // result of expanding a LetSyntaxTT, and thus doesn't
+            // need to be marked. Not that it could be marked anyway.
+            // create issue to recommend refactoring here?
             fld.extsbox.insert(intern(name.as_slice()), ext);
             if attr::contains_name(it.attrs.as_slice(), "macro_export") {
                 SmallVector::one(it)
@@ -1466,6 +1468,15 @@ macro_rules! add_method (($T:ty) =>
             0)
     }
 
+    // macro_rules in method position
+    #[test] fn macro_in_method_posn(){
+        expand_crate_str(
+            "macro_rules! my_method (() => fn thirteen(&self) -> int {13})
+            struct A;
+            impl A{ my_method!()}
+            fn f(){A.thirteen;}".to_string());
+    }
+
     // run one of the renaming tests
     fn run_renaming_test(t: &RenamingTest, test_idx: uint) {
         let invalid_name = token::special_idents::invalid.name;