about summary refs log tree commit diff
path: root/compiler/rustc_parse/src/parser
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2022-11-07 13:19:36 +0000
committerbors <bors@rust-lang.org>2022-11-07 13:19:36 +0000
commit68f77297c0f199e00ff98f4b6bd71a74e75ec09c (patch)
tree7af50e3e584c436407d65d26295f28e4f5cf3b11 /compiler/rustc_parse/src/parser
parent391ba78ab442610a63310b9a3d24646082628081 (diff)
parent81b8db2675330c5d7c0af2db2b90311bd1aec976 (diff)
downloadrust-68f77297c0f199e00ff98f4b6bd71a74e75ec09c.tar.gz
rust-68f77297c0f199e00ff98f4b6bd71a74e75ec09c.zip
Auto merge of #104102 - Dylan-DPC:rollup-0eakshe, r=Dylan-DPC
Rollup of 6 pull requests

Successful merges:

 - #103757 (Mention const and lifetime parameters in error E0207)
 - #103986 (Don't silently eat label before block in block-like expr)
 - #104003 (Move some tests to more reasonable directories)
 - #104038 (Normalize types when deducing closure signature from supertraits)
 - #104052 (Fix `resolution_failure` ICE)
 - #104090 (Modify comment syntax error)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
Diffstat (limited to 'compiler/rustc_parse/src/parser')
-rw-r--r--compiler/rustc_parse/src/parser/diagnostics.rs12
1 files changed, 8 insertions, 4 deletions
diff --git a/compiler/rustc_parse/src/parser/diagnostics.rs b/compiler/rustc_parse/src/parser/diagnostics.rs
index 7dc4fd0044f..c609aa93da3 100644
--- a/compiler/rustc_parse/src/parser/diagnostics.rs
+++ b/compiler/rustc_parse/src/parser/diagnostics.rs
@@ -2468,11 +2468,15 @@ impl<'a> Parser<'a> {
     }
 
     pub(crate) fn maybe_recover_unexpected_block_label(&mut self) -> bool {
-        let Some(label) = self.eat_label().filter(|_| {
-            self.eat(&token::Colon) && self.token.kind == token::OpenDelim(Delimiter::Brace)
-        }) else {
+        // Check for `'a : {`
+        if !(self.check_lifetime()
+            && self.look_ahead(1, |tok| tok.kind == token::Colon)
+            && self.look_ahead(2, |tok| tok.kind == token::OpenDelim(Delimiter::Brace)))
+        {
             return false;
-        };
+        }
+        let label = self.eat_label().expect("just checked if a label exists");
+        self.bump(); // eat `:`
         let span = label.ident.span.to(self.prev_token.span);
         let mut err = self.struct_span_err(span, "block label not supported here");
         err.span_label(span, "not supported here");