about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorKeegan McAllister <kmcallister@mozilla.com>2015-02-13 12:52:33 -0800
committerKeegan McAllister <kmcallister@mozilla.com>2015-02-13 12:54:58 -0800
commit228603d9d210d121599ca384d2a66a90ba4299e1 (patch)
treee481c09510b2d3ea1900970bd08bf4c22672780c /src
parentcf636c233dfeef5abf0de8fb35e23c0a161810d2 (diff)
downloadrust-228603d9d210d121599ca384d2a66a90ba4299e1.tar.gz
rust-228603d9d210d121599ca384d2a66a90ba4299e1.zip
Parse `pub` in the expansion of a method macro
Fixes #17436.
Diffstat (limited to 'src')
-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();
+}