diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/libsyntax/ext/quote.rs | 9 | ||||
| -rw-r--r-- | src/libsyntax/parse/parser.rs | 7 | ||||
| -rw-r--r-- | src/test/run-pass-fulldeps/quote-tokens.rs | 1 |
3 files changed, 10 insertions, 7 deletions
diff --git a/src/libsyntax/ext/quote.rs b/src/libsyntax/ext/quote.rs index 0503c1e8cc2..e8949c4aa4f 100644 --- a/src/libsyntax/ext/quote.rs +++ b/src/libsyntax/ext/quote.rs @@ -464,13 +464,8 @@ pub fn expand_quote_method(cx: &mut ExtCtxt, sp: Span, tts: &[ast::TokenTree]) -> Box<base::MacResult+'static> { - let e_attrs = cx.expr_vec_ng(sp); - let e_visibility = cx.expr_path(cx.path_global(sp, vec!( - id_ext("syntax"), - id_ext("ast"), - id_ext("Inherited")))); - let expanded = expand_parse_call(cx, sp, "parse_method", - vec!(e_attrs, e_visibility), tts); + let expanded = expand_parse_call(cx, sp, "parse_method_with_outer_attributes", + vec!(), tts); base::MacExpr::new(expanded) } diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 6ab14417265..9bfb593786e 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -4371,6 +4371,13 @@ impl<'a> Parser<'a> { (ident, ItemFn(decl, fn_style, abi, generics, body), Some(inner_attrs)) } + /// Parse a method in a trait impl + pub fn parse_method_with_outer_attributes(&mut self) -> P<Method> { + let attrs = self.parse_outer_attributes(); + let visa = self.parse_visibility(); + self.parse_method(attrs, visa) + } + /// Parse a method in a trait impl, starting with `attrs` attributes. pub fn parse_method(&mut self, attrs: Vec<Attribute>, diff --git a/src/test/run-pass-fulldeps/quote-tokens.rs b/src/test/run-pass-fulldeps/quote-tokens.rs index 7b48e7a84b6..8a640387da2 100644 --- a/src/test/run-pass-fulldeps/quote-tokens.rs +++ b/src/test/run-pass-fulldeps/quote-tokens.rs @@ -37,6 +37,7 @@ fn syntax_extension(cx: &ExtCtxt) { assert!(i.is_some()); let _j: P<syntax::ast::Method> = quote_method!(cx, fn foo(&self) {}); + let _k: P<syntax::ast::Method> = quote_method!(cx, #[doc = "hello"] fn foo(&self) {}); } fn main() { |
