diff options
| author | bors <bors@rust-lang.org> | 2023-02-02 17:56:53 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2023-02-02 17:56:53 +0000 |
| commit | f3126500f25114ba4e0ac3e76694dd45a22de56d (patch) | |
| tree | ab016ef14231c6193f6a9d086fca0cda4a159f9a /compiler/rustc_parse/src/parser | |
| parent | 97872b792c9dd6a9bc5c3f4e62a0bd5958b09cdc (diff) | |
| parent | 08181eabfeb468e22e5ce179492979d57d0cdf85 (diff) | |
| download | rust-f3126500f25114ba4e0ac3e76694dd45a22de56d.tar.gz rust-f3126500f25114ba4e0ac3e76694dd45a22de56d.zip | |
Auto merge of #107601 - matthiaskrgr:rollup-07zaafe, r=matthiaskrgr
Rollup of 7 pull requests Successful merges: - #106919 (Recover `_` as `..` in field pattern) - #107493 (Improve diagnostic for missing space in range pattern) - #107515 (Improve pretty-printing of `HirIdValidator` errors) - #107524 (Remove both StorageLive and StorageDead in CopyProp.) - #107532 (Erase regions before doing uninhabited check in borrowck) - #107559 (Rename `rust_2015` → `is_rust_2015`) - #107577 (Reinstate the `hir-stats.rs` tests on stage 1.) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
Diffstat (limited to 'compiler/rustc_parse/src/parser')
| -rw-r--r-- | compiler/rustc_parse/src/parser/expr.rs | 8 | ||||
| -rw-r--r-- | compiler/rustc_parse/src/parser/item.rs | 2 | ||||
| -rw-r--r-- | compiler/rustc_parse/src/parser/pat.rs | 20 | ||||
| -rw-r--r-- | compiler/rustc_parse/src/parser/ty.rs | 2 |
4 files changed, 22 insertions, 10 deletions
diff --git a/compiler/rustc_parse/src/parser/expr.rs b/compiler/rustc_parse/src/parser/expr.rs index b7a023868fc..3d42a9dcbbe 100644 --- a/compiler/rustc_parse/src/parser/expr.rs +++ b/compiler/rustc_parse/src/parser/expr.rs @@ -2717,6 +2717,14 @@ impl<'a> Parser<'a> { ); err.emit(); this.bump(); + } else if matches!( + (&this.prev_token.kind, &this.token.kind), + (token::DotDotEq, token::Gt) + ) { + // `error_inclusive_range_match_arrow` handles cases like `0..=> {}`, + // so we supress the error here + err.delay_as_bug(); + this.bump(); } else { return Err(err); } diff --git a/compiler/rustc_parse/src/parser/item.rs b/compiler/rustc_parse/src/parser/item.rs index 81fd084ccb3..628e9d88cf1 100644 --- a/compiler/rustc_parse/src/parser/item.rs +++ b/compiler/rustc_parse/src/parser/item.rs @@ -2247,7 +2247,7 @@ impl<'a> Parser<'a> { let ext = self.parse_extern(case); if let Async::Yes { span, .. } = asyncness { - if span.rust_2015() { + if span.is_rust_2015() { self.sess.emit_err(AsyncFnIn2015 { span, help: HelpUseLatestEdition::new() }); } } diff --git a/compiler/rustc_parse/src/parser/pat.rs b/compiler/rustc_parse/src/parser/pat.rs index e75554ba124..b054dc59a0c 100644 --- a/compiler/rustc_parse/src/parser/pat.rs +++ b/compiler/rustc_parse/src/parser/pat.rs @@ -743,7 +743,7 @@ impl<'a> Parser<'a> { } token::Gt if no_space => { let after_pat = span.with_hi(span.hi() - rustc_span::BytePos(1)).shrink_to_hi(); - self.sess.emit_err(InclusiveRangeMatchArrow { span, after_pat }); + self.sess.emit_err(InclusiveRangeMatchArrow { span, arrow: tok.span, after_pat }); } _ => { self.sess.emit_err(InclusiveRangeNoEnd { span }); @@ -962,12 +962,15 @@ impl<'a> Parser<'a> { } ate_comma = false; - if self.check(&token::DotDot) || self.token == token::DotDotDot { + if self.check(&token::DotDot) + || self.check_noexpect(&token::DotDotDot) + || self.check_keyword(kw::Underscore) + { etc = true; let mut etc_sp = self.token.span; - self.recover_one_fewer_dotdot(); - self.bump(); // `..` || `...` + self.recover_bad_dot_dot(); + self.bump(); // `..` || `...` || `_` if self.token == token::CloseDelim(Delimiter::Brace) { etc_span = Some(etc_sp); @@ -1060,14 +1063,15 @@ impl<'a> Parser<'a> { Ok((fields, etc)) } - /// Recover on `...` as if it were `..` to avoid further errors. + /// Recover on `...` or `_` as if it were `..` to avoid further errors. /// See issue #46718. - fn recover_one_fewer_dotdot(&self) { - if self.token != token::DotDotDot { + fn recover_bad_dot_dot(&self) { + if self.token == token::DotDot { return; } - self.sess.emit_err(DotDotDotForRemainingFields { span: self.token.span }); + let token_str = pprust::token_to_string(&self.token); + self.sess.emit_err(DotDotDotForRemainingFields { span: self.token.span, token_str }); } fn parse_pat_field(&mut self, lo: Span, attrs: AttrVec) -> PResult<'a, PatField> { diff --git a/compiler/rustc_parse/src/parser/ty.rs b/compiler/rustc_parse/src/parser/ty.rs index 646e2f45e64..a19ea04fa5e 100644 --- a/compiler/rustc_parse/src/parser/ty.rs +++ b/compiler/rustc_parse/src/parser/ty.rs @@ -614,7 +614,7 @@ impl<'a> Parser<'a> { /// Is a `dyn B0 + ... + Bn` type allowed here? fn is_explicit_dyn_type(&mut self) -> bool { self.check_keyword(kw::Dyn) - && (!self.token.uninterpolated_span().rust_2015() + && (self.token.uninterpolated_span().rust_2018() || self.look_ahead(1, |t| { (t.can_begin_bound() || t.kind == TokenKind::BinOp(token::Star)) && !can_continue_type_after_non_fn_ident(t) |
