Skip to content

Commit 3e1608c

Browse files
committed
Use struct name as span instead of entire block
``` 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 ```
1 parent 6483bdd commit 3e1608c

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/libsyntax/parse/parser.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ bitflags! {
7171
}
7272
}
7373

74-
type ItemInfo = (Ident, ItemKind, Option<Vec<Attribute> >);
74+
type ItemInfo = (Ident, ItemKind, Option<Vec<Attribute>>);
7575

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

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

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

5053-
Ok((class_name, ItemKind::Struct(vdata, generics), None))
5054+
Ok(((class_name, ItemKind::Struct(vdata, generics), None), sp))
50545055
}
50555056

50565057
/// Parse union Foo { ... }
@@ -5920,10 +5921,9 @@ impl<'a> Parser<'a> {
59205921
}
59215922
if self.eat_keyword(keywords::Struct) {
59225923
// STRUCT ITEM
5923-
let (ident, item_, extra_attrs) = self.parse_item_struct()?;
5924-
let prev_span = self.prev_span;
5925-
let item = self.mk_item(lo,
5926-
prev_span.hi,
5924+
let ((ident, item_, extra_attrs), sp) = self.parse_item_struct()?;
5925+
let item = self.mk_item(sp.lo,
5926+
sp.hi,
59275927
ident,
59285928
item_,
59295929
visibility,

0 commit comments

Comments
 (0)