diff options
| author | bors <bors@rust-lang.org> | 2018-02-25 02:07:14 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2018-02-25 02:07:14 +0000 |
| commit | 026339e42ba11a559767029d933d1197aefb877a (patch) | |
| tree | 884a690f24c660b4ece0ea6818846920f82631f4 /src/libsyntax/parse | |
| parent | 28a1e4ffefa2620ad9f4179ea339833448874fd3 (diff) | |
| parent | 52047f0ba0d1b1144073963b9b009399d32fb984 (diff) | |
| download | rust-026339e42ba11a559767029d933d1197aefb877a.tar.gz rust-026339e42ba11a559767029d933d1197aefb877a.zip | |
Auto merge of #48520 - Manishearth:rollup, r=Manishearth
Rollup of 15 pull requests - Successful merges: #47689, #48110, #48197, #48296, #48386, #48392, #48404, #48415, #48441, #48448, #48452, #48481, #48490, #48499, #48503 - Failed merges:
Diffstat (limited to 'src/libsyntax/parse')
| -rw-r--r-- | src/libsyntax/parse/parser.rs | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index efc191f24ac..4d457f4864a 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -405,11 +405,14 @@ impl TokenType { } } -// Returns true if `IDENT t` can start a type - `IDENT::a::b`, `IDENT<u8, u8>`, -// `IDENT<<u8 as Trait>::AssocTy>`, `IDENT(u8, u8) -> u8`. -fn can_continue_type_after_ident(t: &token::Token) -> bool { +/// Returns true if `IDENT t` can start a type - `IDENT::a::b`, `IDENT<u8, u8>`, +/// `IDENT<<u8 as Trait>::AssocTy>`. +/// +/// Types can also be of the form `IDENT(u8, u8) -> u8`, however this assumes +/// that IDENT is not the ident of a fn trait +fn can_continue_type_after_non_fn_ident(t: &token::Token) -> bool { t == &token::ModSep || t == &token::Lt || - t == &token::BinOp(token::Shl) || t == &token::OpenDelim(token::Paren) + t == &token::BinOp(token::Shl) } /// Information about the path to a module. @@ -1321,7 +1324,7 @@ impl<'a> Parser<'a> { pub fn token_is_bare_fn_keyword(&mut self) -> bool { self.check_keyword(keywords::Fn) || self.check_keyword(keywords::Unsafe) || - self.check_keyword(keywords::Extern) + self.check_keyword(keywords::Extern) && self.is_extern_non_path() } fn eat_label(&mut self) -> Option<Label> { @@ -1619,7 +1622,8 @@ impl<'a> Parser<'a> { impl_dyn_multi = bounds.len() > 1 || self.prev_token_kind == PrevTokenKind::Plus; TyKind::ImplTrait(bounds) } else if self.check_keyword(keywords::Dyn) && - self.look_ahead(1, |t| t.can_begin_bound() && !can_continue_type_after_ident(t)) { + self.look_ahead(1, |t| t.can_begin_bound() && + !can_continue_type_after_non_fn_ident(t)) { self.bump(); // `dyn` // Always parse bounds greedily for better error recovery. let bounds = self.parse_ty_param_bounds()?; @@ -3224,7 +3228,7 @@ impl<'a> Parser<'a> { -> PResult<'a, P<Expr>> { let lo = self.prev_span; self.expect_keyword(keywords::Let)?; - let pat = self.parse_pat()?; + let pats = self.parse_pats()?; self.expect(&token::Eq)?; let expr = self.parse_expr_res(Restrictions::NO_STRUCT_LITERAL, None)?; let thn = self.parse_block()?; @@ -3234,7 +3238,7 @@ impl<'a> Parser<'a> { } else { (thn.span, None) }; - Ok(self.mk_expr(lo.to(hi), ExprKind::IfLet(pat, expr, thn, els), attrs)) + Ok(self.mk_expr(lo.to(hi), ExprKind::IfLet(pats, expr, thn, els), attrs)) } // `move |args| expr` @@ -3325,13 +3329,13 @@ impl<'a> Parser<'a> { span_lo: Span, mut attrs: ThinVec<Attribute>) -> PResult<'a, P<Expr>> { self.expect_keyword(keywords::Let)?; - let pat = self.parse_pat()?; + let pats = self.parse_pats()?; self.expect(&token::Eq)?; let expr = self.parse_expr_res(Restrictions::NO_STRUCT_LITERAL, None)?; let (iattrs, body) = self.parse_inner_attrs_and_block()?; attrs.extend(iattrs); let span = span_lo.to(body.span); - return Ok(self.mk_expr(span, ExprKind::WhileLet(pat, expr, body, opt_label), attrs)); + return Ok(self.mk_expr(span, ExprKind::WhileLet(pats, expr, body, opt_label), attrs)); } // parse `loop {...}`, `loop` token already eaten |
