Skip to content

Commit d36dc15

Browse files
committed
auto merge of #20794 : sfackler/rust/trailing-attrs, r=alexcrichton
Closes #20711
2 parents 391e010 + cbd962e commit d36dc15

File tree

4 files changed

+49
-5
lines changed

4 files changed

+49
-5
lines changed

src/libcore/str/mod.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1616,22 +1616,25 @@ impl<'a> Iterator for Lines<'a> {
16161616
fn next(&mut self) -> Option<&'a str> { self.inner.next() }
16171617
#[inline]
16181618
fn size_hint(&self) -> (uint, Option<uint>) { self.inner.size_hint() }
1619+
}
16191620

1620-
#[stable]}
1621+
#[stable]
16211622
impl<'a> DoubleEndedIterator for Lines<'a> {
16221623
#[inline]
16231624
fn next_back(&mut self) -> Option<&'a str> { self.inner.next_back() }
1625+
}
16241626

1625-
#[stable]}
1627+
#[stable]
16261628
impl<'a> Iterator for LinesAny<'a> {
16271629
type Item = &'a str;
16281630

16291631
#[inline]
16301632
fn next(&mut self) -> Option<&'a str> { self.inner.next() }
16311633
#[inline]
16321634
fn size_hint(&self) -> (uint, Option<uint>) { self.inner.size_hint() }
1635+
}
16331636

1634-
#[stable]}
1637+
#[stable]
16351638
impl<'a> DoubleEndedIterator for LinesAny<'a> {
16361639
#[inline]
16371640
fn next_back(&mut self) -> Option<&'a str> { self.inner.next_back() }

src/libsyntax/parse/parser.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4769,8 +4769,12 @@ impl<'a> Parser<'a> {
47694769
self.expect(&token::OpenDelim(token::Brace));
47704770
let (inner_attrs, mut method_attrs) =
47714771
self.parse_inner_attrs_and_next();
4772-
while !self.eat(&token::CloseDelim(token::Brace)) {
4772+
loop {
47734773
method_attrs.extend(self.parse_outer_attributes().into_iter());
4774+
if method_attrs.is_empty() && self.eat(&token::CloseDelim(token::Brace)) {
4775+
break;
4776+
}
4777+
47744778
let vis = self.parse_visibility();
47754779
if self.eat_keyword(keywords::Type) {
47764780
impl_items.push(TypeImplItem(P(self.parse_typedef(
@@ -4781,7 +4785,7 @@ impl<'a> Parser<'a> {
47814785
method_attrs,
47824786
vis)));
47834787
}
4784-
method_attrs = self.parse_outer_attributes();
4788+
method_attrs = vec![];
47854789
}
47864790
(impl_items, inner_attrs)
47874791
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
struct Foo;
12+
13+
impl Foo {
14+
fn foo() {}
15+
16+
#[stable]
17+
} //~ ERROR expected `fn`, found `}`
18+
19+
fn main() {}
20+

src/test/compile-fail/issue-20711.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
struct Foo;
12+
13+
impl Foo {
14+
#[stable]
15+
} //~ ERROR expected `fn`, found `}`
16+
17+
fn main() {}

0 commit comments

Comments
 (0)