about summary refs log tree commit diff
diff options
context:
space:
mode:
authorManish Goregaokar <manishsmail@gmail.com>2015-02-15 18:34:53 +0530
committerManish Goregaokar <manishsmail@gmail.com>2015-02-15 18:42:47 +0530
commitbc1900f0d0ce09e26c5b0693d83516a4d0cf505f (patch)
tree97cc9a46ea23a8867a4506debfa16f18299aa57c
parentf7870b6faa43a9e63b5575d5d9663457003a8ac5 (diff)
parent228603d9d210d121599ca384d2a66a90ba4299e1 (diff)
downloadrust-bc1900f0d0ce09e26c5b0693d83516a4d0cf505f.tar.gz
rust-bc1900f0d0ce09e26c5b0693d83516a4d0cf505f.zip
Rollup merge of #22300 - kmcallister:pub-method-macro, r=sfackler
 Fixes #17436.
-rw-r--r--src/libsyntax/ext/tt/macro_rules.rs3
-rw-r--r--src/test/run-pass/pub-method-inside-macro.rs29
2 files changed, 30 insertions, 2 deletions
diff --git a/src/libsyntax/ext/tt/macro_rules.rs b/src/libsyntax/ext/tt/macro_rules.rs
index de61bdefa5d..f322cf8bad0 100644
--- a/src/libsyntax/ext/tt/macro_rules.rs
+++ b/src/libsyntax/ext/tt/macro_rules.rs
@@ -89,8 +89,7 @@ impl<'a> MacResult for ParserAnyMacro<'a> {
             match parser.token {
                 token::Eof => break,
                 _ => {
-                    let attrs = parser.parse_outer_attributes();
-                    ret.push(parser.parse_method(attrs, ast::Inherited))
+                    ret.push(parser.parse_method_with_outer_attributes());
                 }
             }
         }
diff --git a/src/test/run-pass/pub-method-inside-macro.rs b/src/test/run-pass/pub-method-inside-macro.rs
new file mode 100644
index 00000000000..af2f217c1fb
--- /dev/null
+++ b/src/test/run-pass/pub-method-inside-macro.rs
@@ -0,0 +1,29 @@
+// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// Issue #17436
+
+mod bleh {
+    macro_rules! foo {
+        () => {
+            pub fn bar(&self) { }
+        }
+    }
+
+    pub struct S;
+
+    impl S {
+        foo!();
+    }
+}
+
+fn main() {
+    bleh::S.bar();
+}