about summary refs log tree commit diff
path: root/src/libsyntax/parse
diff options
context:
space:
mode:
authorHuon Wilson <dbau.pp+github@gmail.com>2013-11-24 11:48:46 +1100
committerHuon Wilson <dbau.pp+github@gmail.com>2013-11-25 19:18:44 +1100
commite36cb0d5c1176f8dcb3538e545c86631d5619f00 (patch)
tree7f849e7136a3cf416b5d58cf6d2210543fbdf3ea /src/libsyntax/parse
parentfb279aa02a7ff2ed069791f60a5159d73c8ed993 (diff)
downloadrust-e36cb0d5c1176f8dcb3538e545c86631d5619f00.tar.gz
rust-e36cb0d5c1176f8dcb3538e545c86631d5619f00.zip
syntax: parse inner attributes on impls.
Fixes #3614.
Diffstat (limited to 'src/libsyntax/parse')
-rw-r--r--src/libsyntax/parse/parser.rs24
1 files changed, 17 insertions, 7 deletions
diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs
index 486a7a800a0..29ccb235f07 100644
--- a/src/libsyntax/parse/parser.rs
+++ b/src/libsyntax/parse/parser.rs
@@ -3871,9 +3871,14 @@ impl Parser {
          Some(inner_attrs))
     }
 
-    // parse a method in a trait impl
-    fn parse_method(&self) -> @method {
-        let attrs = self.parse_outer_attributes();
+    // parse a method in a trait impl, starting with `attrs` attributes.
+    fn parse_method(&self, already_parsed_attrs: Option<~[Attribute]>) -> @method {
+        let next_attrs = self.parse_outer_attributes();
+        let attrs = match already_parsed_attrs {
+            Some(mut a) => { a.push_all_move(next_attrs); a }
+            None => next_attrs
+        };
+
         let lo = self.span.lo;
 
         let visa = self.parse_visibility();
@@ -3966,16 +3971,21 @@ impl Parser {
         };
 
         let mut meths = ~[];
-        if self.eat(&token::SEMI) {
+        let inner_attrs = if self.eat(&token::SEMI) {
             self.obsolete(*self.last_span, ObsoleteEmptyImpl);
+            None
         } else {
             self.expect(&token::LBRACE);
+            let (inner_attrs, next) = self.parse_inner_attrs_and_next();
+            let mut method_attrs = Some(next);
             while !self.eat(&token::RBRACE) {
-                meths.push(self.parse_method());
+                meths.push(self.parse_method(method_attrs));
+                method_attrs = None;
             }
-        }
+            Some(inner_attrs)
+        };
 
-        (ident, item_impl(generics, opt_trait, ty, meths), None)
+        (ident, item_impl(generics, opt_trait, ty, meths), inner_attrs)
     }
 
     // parse a::B<~str,int>