Skip to content

Commit 5a61d43

Browse files
committed
Rollup merge of #24739 - nrc:span-item, r=huonw
(And other kinds of items). This brings trait/impl items in line with top-level items in this respect. It means we don't get the attributes when showing error messages for methods, etc. (a good thing, I think). Since attributes have spans it is still easy to create a span for the item + all attributes.
2 parents cda0083 + 17934e5 commit 5a61d43

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

src/libsyntax/parse/parser.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1151,8 +1151,8 @@ impl<'a> Parser<'a> {
11511151
&token::CloseDelim(token::Brace),
11521152
seq_sep_none(),
11531153
|p| {
1154-
let lo = p.span.lo;
11551154
let mut attrs = p.parse_outer_attributes();
1155+
let lo = p.span.lo;
11561156

11571157
let (name, node) = if try!(p.eat_keyword(keywords::Type)) {
11581158
let TyParam {ident, bounds, default, ..} = try!(p.parse_ty_param());
@@ -3409,8 +3409,8 @@ impl<'a> Parser<'a> {
34093409
}
34103410
}
34113411

3412-
let lo = self.span.lo;
34133412
let attrs = self.parse_outer_attributes();
3413+
let lo = self.span.lo;
34143414

34153415
Ok(Some(if self.check_keyword(keywords::Let) {
34163416
check_expected_item(self, &attrs);
@@ -4304,8 +4304,8 @@ impl<'a> Parser<'a> {
43044304

43054305
/// Parse an impl item.
43064306
pub fn parse_impl_item(&mut self) -> PResult<P<ImplItem>> {
4307-
let lo = self.span.lo;
43084307
let mut attrs = self.parse_outer_attributes();
4308+
let lo = self.span.lo;
43094309
let vis = try!(self.parse_visibility());
43104310
let (name, node) = if try!(self.eat_keyword(keywords::Type)) {
43114311
let name = try!(self.parse_ident());
@@ -5380,9 +5380,8 @@ impl<'a> Parser<'a> {
53805380

53815381
/// Parse a foreign item.
53825382
fn parse_foreign_item(&mut self) -> PResult<Option<P<ForeignItem>>> {
5383-
let lo = self.span.lo;
5384-
53855383
let attrs = self.parse_outer_attributes();
5384+
let lo = self.span.lo;
53865385
let visibility = try!(self.parse_visibility());
53875386

53885387
if self.check_keyword(keywords::Static) {

0 commit comments

Comments
 (0)