@@ -1051,7 +1051,7 @@ impl<'a> Parser<'a> {
1051
1051
pub fn parse_for_in_type(&mut self) -> PResult<'a, TyKind> {
1052
1052
/*
1053
1053
Parses whatever can come after a `for` keyword in a type.
1054
- The `for` has already been consumed.
1054
+ The `for` hasn't been consumed.
1055
1055
1056
1056
Deprecated:
1057
1057
@@ -1091,6 +1091,23 @@ impl<'a> Parser<'a> {
1091
1091
}
1092
1092
}
1093
1093
1094
+ pub fn parse_impl_trait_type(&mut self) -> PResult<'a, TyKind> {
1095
+ /*
1096
+ Parses whatever can come after a `impl` keyword in a type.
1097
+ The `impl` has already been consumed.
1098
+ */
1099
+
1100
+ let bounds = self.parse_ty_param_bounds(BoundParsingMode::Modified)?;
1101
+
1102
+ if !bounds.iter().any(|b| if let TraitTyParamBound(..) = *b { true } else { false }) {
1103
+ let last_span = self.last_span;
1104
+ self.span_err(last_span, "at least one trait must be specified");
1105
+ }
1106
+
1107
+ Ok(ast::TyKind::ImplTrait(bounds))
1108
+ }
1109
+
1110
+
1094
1111
pub fn parse_ty_path(&mut self) -> PResult<'a, TyKind> {
1095
1112
Ok(TyKind::Path(None, self.parse_path(PathStyle::Type)?))
1096
1113
}
@@ -1406,6 +1423,8 @@ impl<'a> Parser<'a> {
1406
1423
self.parse_borrowed_pointee()?
1407
1424
} else if self.check_keyword(keywords::For) {
1408
1425
self.parse_for_in_type()?
1426
+ } else if self.eat_keyword(keywords::Impl) {
1427
+ self.parse_impl_trait_type()?
1409
1428
} else if self.token_is_bare_fn_keyword() {
1410
1429
// BARE FUNCTION
1411
1430
self.parse_ty_bare_fn(Vec::new())?
0 commit comments