Skip to content

Commit

Permalink
Use struct name as span instead of entire block
Browse files Browse the repository at this point in the history
```
error[E0072]: recursive type `ListNode` has infinite size
  --> ../../../src/test/compile-fail/E0072.rs:11:8
   |
11 | struct ListNode { //~ ERROR E0072
   |        ^^^^^^^^ recursive type has infinite size
   |
   = help: insert indirection (e.g., a `Box`, `Rc`, or `&`) at some point to make `ListNode` representable
```
  • Loading branch information
estebank committed Dec 13, 2016
1 parent 6483bdd commit 3e1608c
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/libsyntax/parse/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ bitflags! {
}
}

type ItemInfo = (Ident, ItemKind, Option<Vec<Attribute> >);
type ItemInfo = (Ident, ItemKind, Option<Vec<Attribute>>);

/// How to parse a path. There are three different kinds of paths, all of which
/// are parsed somewhat differently.
Expand Down Expand Up @@ -5005,8 +5005,9 @@ impl<'a> Parser<'a> {
}

/// Parse struct Foo { ... }
fn parse_item_struct(&mut self) -> PResult<'a, ItemInfo> {
fn parse_item_struct(&mut self) -> PResult<'a, (ItemInfo, Span)> {
let class_name = self.parse_ident()?;
let sp = self.prev_span; // struct's name's span
let mut generics = self.parse_generics()?;

// There is a special case worth noting here, as reported in issue #17904.
Expand Down Expand Up @@ -5050,7 +5051,7 @@ impl<'a> Parser<'a> {
name, found `{}`", token_str)))
};

Ok((class_name, ItemKind::Struct(vdata, generics), None))
Ok(((class_name, ItemKind::Struct(vdata, generics), None), sp))
}

/// Parse union Foo { ... }
Expand Down Expand Up @@ -5920,10 +5921,9 @@ impl<'a> Parser<'a> {
}
if self.eat_keyword(keywords::Struct) {
// STRUCT ITEM
let (ident, item_, extra_attrs) = self.parse_item_struct()?;
let prev_span = self.prev_span;
let item = self.mk_item(lo,
prev_span.hi,
let ((ident, item_, extra_attrs), sp) = self.parse_item_struct()?;
let item = self.mk_item(sp.lo,
sp.hi,
ident,
item_,
visibility,
Expand Down

0 comments on commit 3e1608c

Please sign in to comment.