From 0e498da47e265b5bb7a4f59bbed53bc843bd83cc Mon Sep 17 00:00:00 2001 From: Brian Anderson Date: Mon, 30 Jan 2012 11:43:45 -0800 Subject: rustc: Allow attributes on methods. Closes #1709 --- src/comp/syntax/parse/parser.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src/comp/syntax/parse') diff --git a/src/comp/syntax/parse/parser.rs b/src/comp/syntax/parse/parser.rs index 272d65707dd..1c81eda7df5 100644 --- a/src/comp/syntax/parse/parser.rs +++ b/src/comp/syntax/parse/parser.rs @@ -282,6 +282,7 @@ fn parse_ty_fn(proto: ast::proto, p: parser) -> ast::ty_ { fn parse_ty_methods(p: parser) -> [ast::ty_method] { parse_seq(token::LBRACE, token::RBRACE, seq_sep_none(), {|p| + let attrs = parse_outer_attributes(p); let flo = p.span.lo; expect_word(p, "fn"); let ident = parse_method_name(p); @@ -290,7 +291,7 @@ fn parse_ty_methods(p: parser) -> [ast::ty_method] { expect(p, token::SEMI); alt f { ast::ty_fn(_, d) { - {ident: ident, decl: d, tps: tps, + {ident: ident, attrs: attrs, decl: d, tps: tps, span: ast_util::mk_sp(flo, fhi)} } } @@ -1849,13 +1850,15 @@ fn parse_method_name(p: parser) -> ast::ident { } fn parse_method(p: parser) -> @ast::method { + let attrs = parse_outer_attributes(p); let lo = p.span.lo; expect_word(p, "fn"); let ident = parse_method_name(p); let tps = parse_ty_params(p); let decl = parse_fn_decl(p, ast::impure_fn); - let body = parse_block(p); - @{ident: ident, tps: tps, decl: decl, body: body, + let (inner_attrs, body) = parse_inner_attrs_and_block(p, true); + let attrs = attrs + inner_attrs; + @{ident: ident, attrs: attrs, tps: tps, decl: decl, body: body, id: p.get_id(), span: ast_util::mk_sp(lo, body.span.hi)} } -- cgit 1.4.1-3-g733a5