|
1 | 1 | use super::{StringReader, UnmatchedBrace}; |
2 | 2 |
|
3 | | -use rustc_ast::token::{self, Token, DelimToken}; |
| 3 | +use rustc_ast::token::{self, DelimToken, Token}; |
4 | 4 | use rustc_ast::tokenstream::{ |
5 | 5 | DelimSpan, |
6 | 6 | IsJoint::{self, *}, |
@@ -238,40 +238,25 @@ impl<'a> TokenTreesReader<'a> { |
238 | 238 | let mut err = |
239 | 239 | self.string_reader.sess.span_diagnostic.struct_span_err(self.token.span, &msg); |
240 | 240 |
|
241 | | - // Braces are added at the end, so the last element is the biggest block |
242 | | - if let Some(parent) = self.matching_block_spans.last() { |
243 | | - |
244 | | - if let Some(span) = self.last_delim_empty_block_spans.remove(&delim) { |
245 | | - // Check if the (empty block) is in the last properly closed block |
246 | | - if (parent.0.to(parent.1)).contains(span) { |
247 | | - err.span_label( |
248 | | - span, |
249 | | - "block is empty, you might have not meant to close it", |
250 | | - ); |
251 | | - } |
252 | | - else { |
253 | | - err.span_label( |
254 | | - parent.0, |
255 | | - "this opening brace...", |
256 | | - ); |
257 | | - |
258 | | - err.span_label( |
259 | | - parent.1, |
260 | | - "...matches this closing brace", |
261 | | - ); |
262 | | - } |
263 | | - } |
264 | | - else { |
| 241 | + // Braces are added at the end, so the last element is the biggest block |
| 242 | + if let Some(parent) = self.matching_block_spans.last() { |
| 243 | + if let Some(span) = self.last_delim_empty_block_spans.remove(&delim) { |
| 244 | + // Check if the (empty block) is in the last properly closed block |
| 245 | + if (parent.0.to(parent.1)).contains(span) { |
265 | 246 | err.span_label( |
266 | | - parent.0, |
267 | | - "this opening brace...", |
| 247 | + span, |
| 248 | + "block is empty, you might have not meant to close it", |
268 | 249 | ); |
| 250 | + } else { |
| 251 | + err.span_label(parent.0, "this opening brace..."); |
269 | 252 |
|
270 | | - err.span_label( |
271 | | - parent.1, |
272 | | - "...matches this closing brace", |
273 | | - ); |
| 253 | + err.span_label(parent.1, "...matches this closing brace"); |
274 | 254 | } |
| 255 | + } else { |
| 256 | + err.span_label(parent.0, "this opening brace..."); |
| 257 | + |
| 258 | + err.span_label(parent.1, "...matches this closing brace"); |
| 259 | + } |
275 | 260 | } |
276 | 261 |
|
277 | 262 | err.span_label(self.token.span, "unexpected closing delimiter"); |
|
0 commit comments