about summary refs log tree commit diff
path: root/src/libsyntax/parse
diff options
context:
space:
mode:
authorSteven Fackler <sfackler@gmail.com>2015-01-08 21:36:30 -0800
committerSteven Fackler <sfackler@gmail.com>2015-01-08 21:36:30 -0800
commitcbd962ebb585732e287478169108099bcc265024 (patch)
tree12ad70f03e19da102fb53ae5c9a76d60244c8796 /src/libsyntax/parse
parent44a287e6eb22ec3c2a687fc156813577464017f7 (diff)
downloadrust-cbd962ebb585732e287478169108099bcc265024.tar.gz
rust-cbd962ebb585732e287478169108099bcc265024.zip
Forbid trailing attributes in impl blocks
Closes #20711
Diffstat (limited to 'src/libsyntax/parse')
-rw-r--r--src/libsyntax/parse/parser.rs8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs
index 531e611594a..33f9e35d8b7 100644
--- a/src/libsyntax/parse/parser.rs
+++ b/src/libsyntax/parse/parser.rs
@@ -4769,8 +4769,12 @@ impl<'a> Parser<'a> {
         self.expect(&token::OpenDelim(token::Brace));
         let (inner_attrs, mut method_attrs) =
             self.parse_inner_attrs_and_next();
-        while !self.eat(&token::CloseDelim(token::Brace)) {
+        loop {
             method_attrs.extend(self.parse_outer_attributes().into_iter());
+            if method_attrs.is_empty() && self.eat(&token::CloseDelim(token::Brace)) {
+                break;
+            }
+
             let vis = self.parse_visibility();
             if self.eat_keyword(keywords::Type) {
                 impl_items.push(TypeImplItem(P(self.parse_typedef(
@@ -4781,7 +4785,7 @@ impl<'a> Parser<'a> {
                             method_attrs,
                             vis)));
             }
-            method_attrs = self.parse_outer_attributes();
+            method_attrs = vec![];
         }
         (impl_items, inner_attrs)
     }