summary refs log tree commit diff
path: root/compiler/rustc_parse/src/parser/mod.rs
diff options
context:
space:
mode:
authorEsteban Kuber <esteban@kuber.com.ar>2021-08-27 10:57:28 +0000
committerEsteban Kuber <esteban@kuber.com.ar>2021-08-27 14:24:47 +0000
commitc6d800d85439d0a95a2943905d0fd3842fa4dd20 (patch)
tree0c7279cdc386f6babf168a5004dedbfadcb8401a /compiler/rustc_parse/src/parser/mod.rs
parent4a6547cca6d2b2f465f01331927855734687b527 (diff)
downloadrust-c6d800d85439d0a95a2943905d0fd3842fa4dd20.tar.gz
rust-c6d800d85439d0a95a2943905d0fd3842fa4dd20.zip
Point at unclosed delimiters as part of the primary MultiSpan
Both the place where the parser encounters a needed closed delimiter and
the unclosed opening delimiter are important, so they should get the
same level of highlighting in the output.
Diffstat (limited to 'compiler/rustc_parse/src/parser/mod.rs')
-rw-r--r--compiler/rustc_parse/src/parser/mod.rs9
1 files changed, 7 insertions, 2 deletions
diff --git a/compiler/rustc_parse/src/parser/mod.rs b/compiler/rustc_parse/src/parser/mod.rs
index 4c3c140d171..64f7a447fea 100644
--- a/compiler/rustc_parse/src/parser/mod.rs
+++ b/compiler/rustc_parse/src/parser/mod.rs
@@ -33,7 +33,7 @@ use rustc_data_structures::sync::Lrc;
 use rustc_errors::PResult;
 use rustc_errors::{struct_span_err, Applicability, DiagnosticBuilder, FatalError};
 use rustc_session::parse::ParseSess;
-use rustc_span::source_map::{Span, DUMMY_SP};
+use rustc_span::source_map::{MultiSpan, Span, DUMMY_SP};
 use rustc_span::symbol::{kw, sym, Ident, Symbol};
 use tracing::debug;
 
@@ -1335,8 +1335,13 @@ crate fn make_unclosed_delims_error(
     // `None` here means an `Eof` was found. We already emit those errors elsewhere, we add them to
     // `unmatched_braces` only for error recovery in the `Parser`.
     let found_delim = unmatched.found_delim?;
+    let span: MultiSpan = if let Some(sp) = unmatched.unclosed_span {
+        vec![unmatched.found_span, sp].into()
+    } else {
+        unmatched.found_span.into()
+    };
     let mut err = sess.span_diagnostic.struct_span_err(
-        unmatched.found_span,
+        span,
         &format!(
             "mismatched closing delimiter: `{}`",
             pprust::token_kind_to_string(&token::CloseDelim(found_delim)),