about summary refs log tree commit diff
path: root/src/libsyntax/parse
diff options
context:
space:
mode:
authorPietro Albini <pietro@pietroalbini.org>2018-12-19 11:47:14 +0100
committerGitHub <noreply@github.com>2018-12-19 11:47:14 +0100
commit5b41887e0e3a6b380bc5ec8fefe16b2ad8a0c9af (patch)
treedfd50f6be49043ba95edbe976d36f8aecffef99f /src/libsyntax/parse
parent2e5a025d443dbefbdb82053112b447ce998d2ab0 (diff)
parent25b3c825084c4743110b2a1cc574c691dc2f0142 (diff)
downloadrust-5b41887e0e3a6b380bc5ec8fefe16b2ad8a0c9af.tar.gz
rust-5b41887e0e3a6b380bc5ec8fefe16b2ad8a0c9af.zip
Rollup merge of #56910 - estebank:unclosed-eof, r=oli-obk
Do not point at delim spans for complete correct blocks

Fix #56834.
Diffstat (limited to 'src/libsyntax/parse')
-rw-r--r--src/libsyntax/parse/lexer/tokentrees.rs10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/libsyntax/parse/lexer/tokentrees.rs b/src/libsyntax/parse/lexer/tokentrees.rs
index 0906c25cab3..6f9dc247a78 100644
--- a/src/libsyntax/parse/lexer/tokentrees.rs
+++ b/src/libsyntax/parse/lexer/tokentrees.rs
@@ -97,7 +97,15 @@ impl<'a> StringReader<'a> {
                     // Correct delimiter.
                     token::CloseDelim(d) if d == delim => {
                         let (open_brace, open_brace_span) = self.open_braces.pop().unwrap();
-                        self.matching_delim_spans.push((open_brace, open_brace_span, self.span));
+                        if self.open_braces.len() == 0 {
+                            // Clear up these spans to avoid suggesting them as we've found
+                            // properly matched delimiters so far for an entire block.
+                            self.matching_delim_spans.clear();
+                        } else {
+                            self.matching_delim_spans.push(
+                                (open_brace, open_brace_span, self.span),
+                            );
+                        }
                         // Parse the close delimiter.
                         self.real_token();
                     }