about summary refs log tree commit diff
path: root/src/comp/syntax/parse
diff options
context:
space:
mode:
authorBrian Anderson <banderson@mozilla.com>2012-01-30 11:43:45 -0800
committerBrian Anderson <banderson@mozilla.com>2012-01-30 11:43:45 -0800
commit0e498da47e265b5bb7a4f59bbed53bc843bd83cc (patch)
treefaa59e85a242835d965df27778221b19aa4db5ad /src/comp/syntax/parse
parent6ba3d2435556ae4ea72eeb6095e95b5c14a3c1f7 (diff)
downloadrust-0e498da47e265b5bb7a4f59bbed53bc843bd83cc.tar.gz
rust-0e498da47e265b5bb7a4f59bbed53bc843bd83cc.zip
rustc: Allow attributes on methods. Closes #1709
Diffstat (limited to 'src/comp/syntax/parse')
-rw-r--r--src/comp/syntax/parse/parser.rs9
1 files changed, 6 insertions, 3 deletions
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)}
 }