diff --git a/src/libsyntax/ext/tt/macro_rules.rs b/src/libsyntax/ext/tt/macro_rules.rs index de61bdefa5de3..f322cf8bad09c 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 0000000000000..af2f217c1fbb2 --- /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 or the MIT license +// , 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(); +}