diff options
| author | bors <bors@rust-lang.org> | 2024-06-20 06:54:19 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2024-06-20 06:54:19 +0000 |
| commit | 1208eddaff59c98e37574c860de6f68aa404958f (patch) | |
| tree | fc24a7fede53cc6f5b05faaafe3e8fa2af5b9a7d /compiler/rustc_parse/src | |
| parent | 54fcd5bb9221da009e2400ae59b525a8a04c5928 (diff) | |
| parent | c979535aa5455b4ad90ff7f3c671c2cd87a89805 (diff) | |
| download | rust-1208eddaff59c98e37574c860de6f68aa404958f.tar.gz rust-1208eddaff59c98e37574c860de6f68aa404958f.zip | |
Auto merge of #126726 - matthiaskrgr:rollup-ppe8ve3, r=matthiaskrgr
Rollup of 5 pull requests Successful merges: - #126620 (Actually taint InferCtxt when a fulfillment error is emitted) - #126649 (Fix `feature = "nightly"` in the new trait solver) - #126652 (Clarify that anonymous consts still do introduce a new scope) - #126703 (reword the hint::blackbox non-guarantees) - #126708 (Minimize `can_begin_literal_maybe_minus` usage) r? `@ghost` `@rustbot` modify labels: rollup
Diffstat (limited to 'compiler/rustc_parse/src')
| -rw-r--r-- | compiler/rustc_parse/src/parser/item.rs | 4 | ||||
| -rw-r--r-- | compiler/rustc_parse/src/parser/pat.rs | 3 |
2 files changed, 4 insertions, 3 deletions
diff --git a/compiler/rustc_parse/src/parser/item.rs b/compiler/rustc_parse/src/parser/item.rs index 2db777a9f70..3e1ea7b129d 100644 --- a/compiler/rustc_parse/src/parser/item.rs +++ b/compiler/rustc_parse/src/parser/item.rs @@ -1259,7 +1259,7 @@ impl<'a> Parser<'a> { self.token.is_keyword(kw::Unsafe) && self.is_keyword_ahead(1, &[kw::Extern]) && self.look_ahead( - 2 + self.look_ahead(2, |t| t.can_begin_literal_maybe_minus() as usize), + 2 + self.look_ahead(2, |t| t.can_begin_string_literal() as usize), |t| t.kind == token::OpenDelim(Delimiter::Brace), ) } @@ -2448,7 +2448,7 @@ impl<'a> Parser<'a> { }) // `extern ABI fn` || self.check_keyword_case(kw::Extern, case) - && self.look_ahead(1, |t| t.can_begin_literal_maybe_minus()) + && self.look_ahead(1, |t| t.can_begin_string_literal()) && (self.look_ahead(2, |t| t.is_keyword_case(kw::Fn, case)) || // this branch is only for better diagnostic in later, `pub` is not allowed here (self.may_recover() diff --git a/compiler/rustc_parse/src/parser/pat.rs b/compiler/rustc_parse/src/parser/pat.rs index 03aea0888d9..6f2b7177159 100644 --- a/compiler/rustc_parse/src/parser/pat.rs +++ b/compiler/rustc_parse/src/parser/pat.rs @@ -939,7 +939,8 @@ impl<'a> Parser<'a> { || self.look_ahead(dist, |t| { t.is_path_start() // e.g. `MY_CONST`; || t.kind == token::Dot // e.g. `.5` for recovery; - || t.can_begin_literal_maybe_minus() // e.g. `42`. + || matches!(t.kind, token::Literal(..) | token::BinOp(token::Minus)) + || t.is_bool_lit() || t.is_whole_expr() || t.is_lifetime() // recover `'a` instead of `'a'` || (self.may_recover() // recover leading `(` |
