From 87738fe83401ee2a7d2556df8db0df4dec7cd58d Mon Sep 17 00:00:00 2001 From: varkor Date: Tue, 30 Jul 2019 00:11:50 +0100 Subject: Switch existential_type to type_alias_impl_trait --- src/libsyntax/parse/parser.rs | 25 +++++++------------------ 1 file changed, 7 insertions(+), 18 deletions(-) (limited to 'src/libsyntax/parse') diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 7096d6799e2..ec95a2090d6 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -6805,40 +6805,29 @@ impl<'a> Parser<'a> { Ok(self.mk_item(lo.to(prev_span), invalid, ItemKind::ForeignMod(m), visibility, attrs)) } - /// Parses `type Foo = Bar;` - /// or - /// `existential type Foo: Bar;` - /// or - /// `return `None`` + /// Parses `type Foo = Bar;` or returns `None` /// without modifying the parser state. fn eat_type(&mut self) -> Option> { // This parses the grammar: // Ident ["<"...">"] ["where" ...] ("=" | ":") Ty ";" - if self.check_keyword(kw::Type) || - self.check_keyword(kw::Existential) && - self.is_keyword_ahead(1, &[kw::Type]) { - let existential = self.eat_keyword(kw::Existential); - assert!(self.eat_keyword(kw::Type)); - Some(self.parse_existential_or_alias(existential)) + if self.eat_keyword(kw::Type) { + Some(self.parse_type_alias()) } else { None } } /// Parses a type alias or existential type. - fn parse_existential_or_alias( - &mut self, - existential: bool, - ) -> PResult<'a, (Ident, AliasKind, ast::Generics)> { + fn parse_type_alias(&mut self) -> PResult<'a, (Ident, AliasKind, ast::Generics)> { let ident = self.parse_ident()?; let mut tps = self.parse_generics()?; tps.where_clause = self.parse_where_clause()?; - let alias = if existential { - self.expect(&token::Colon)?; + self.expect(&token::Eq)?; + let alias = if self.check_keyword(kw::Impl) { + self.bump(); let bounds = self.parse_generic_bounds(Some(self.prev_span))?; AliasKind::Existential(bounds) } else { - self.expect(&token::Eq)?; let ty = self.parse_ty()?; AliasKind::Weak(ty) }; -- cgit 1.4.1-3-g733a5