1
Fork 0

libsyntax: remove dead code from parser.rs

Both `parse_tuple_struct_body` and `parse_item_struct` handled the case
of unit like struct. The redundancy is removed,
`parse_tuple_struct_body` now handles only real tuple structs.
This commit is contained in:
Aleksey Kladov 2015-09-07 20:08:57 +03:00
parent 0762f58c11
commit c8da5697e0

View file

@ -4769,7 +4769,7 @@ impl<'a> Parser<'a> {
generics: &mut ast::Generics)
-> PResult<Vec<StructField>> {
// This is the case where we find `struct Foo<T>(T) where T: Copy;`
if self.check(&token::OpenDelim(token::Paren)) {
// Unit like structs are handled in parse_item_struct function
let fields = try!(self.parse_unspanned_seq(
&token::OpenDelim(token::Paren),
&token::CloseDelim(token::Paren),
@ -4795,17 +4795,6 @@ impl<'a> Parser<'a> {
generics.where_clause = try!(self.parse_where_clause());
try!(self.expect(&token::Semi));
Ok(fields)
// This is the case where we just see struct Foo<T> where T: Copy;
} else if self.token.is_keyword(keywords::Where) {
generics.where_clause = try!(self.parse_where_clause());
try!(self.expect(&token::Semi));
Ok(Vec::new())
// This case is where we see: `struct Foo<T>;`
} else {
let token_str = self.this_token_to_string();
Err(self.fatal(&format!("expected `where`, `{}`, `(`, or `;` after struct \
name, found `{}`", "{", token_str)))
}
}
/// Parse a structure field declaration