summary refs log tree commit diff
path: root/compiler/rustc_parse/src/parser
diff options
context:
space:
mode:
authorYuki Okushi <yuki.okushi@huawei.com>2021-06-18 10:22:23 +0900
committerYuki Okushi <yuki.okushi@huawei.com>2021-09-17 13:14:23 +0900
commit58765d61ee1762ce0dd9565074000cb9c1267a02 (patch)
tree2953c0306ea3ff37074a55a27ca5f348cfad8d7b /compiler/rustc_parse/src/parser
parent78a46efff06558674b51c10d8d81758285746ab5 (diff)
downloadrust-58765d61ee1762ce0dd9565074000cb9c1267a02.tar.gz
rust-58765d61ee1762ce0dd9565074000cb9c1267a02.zip
Emit clearer diagnostics for parens around `for` loop heads
Diffstat (limited to 'compiler/rustc_parse/src/parser')
-rw-r--r--compiler/rustc_parse/src/parser/diagnostics.rs5
1 files changed, 3 insertions, 2 deletions
diff --git a/compiler/rustc_parse/src/parser/diagnostics.rs b/compiler/rustc_parse/src/parser/diagnostics.rs
index 4fccfc287fd..ab7478c7e5f 100644
--- a/compiler/rustc_parse/src/parser/diagnostics.rs
+++ b/compiler/rustc_parse/src/parser/diagnostics.rs
@@ -1346,8 +1346,9 @@ impl<'a> Parser<'a> {
                     .span_to_snippet(pat.span.trim_start(begin_par_sp).unwrap())
                     .unwrap_or_else(|_| pprust::pat_to_string(&pat));
 
-                self.struct_span_err(self.prev_token.span, "unexpected closing `)`")
-                    .span_label(begin_par_sp, "opening `(`")
+                let sp = MultiSpan::from_spans(vec![begin_par_sp, self.prev_token.span]);
+
+                self.struct_span_err(sp, "unexpected parenthesis surrounding `for` loop head")
                     .span_suggestion(
                         begin_par_sp.to(self.prev_token.span),
                         "remove parenthesis in `for` loop",