Skip to content

Commit

Permalink
Run fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
kper committed Apr 4, 2020
1 parent 2c6f846 commit f96b92f
Showing 1 changed file with 16 additions and 31 deletions.
47 changes: 16 additions & 31 deletions src/librustc_parse/lexer/tokentrees.rs
@@ -1,6 +1,6 @@
use super::{StringReader, UnmatchedBrace};

use rustc_ast::token::{self, Token, DelimToken};
use rustc_ast::token::{self, DelimToken, Token};
use rustc_ast::tokenstream::{
DelimSpan,
IsJoint::{self, *},
Expand Down Expand Up @@ -238,40 +238,25 @@ impl<'a> TokenTreesReader<'a> {
let mut err =
self.string_reader.sess.span_diagnostic.struct_span_err(self.token.span, &msg);

// Braces are added at the end, so the last element is the biggest block
if let Some(parent) = self.matching_block_spans.last() {

if let Some(span) = self.last_delim_empty_block_spans.remove(&delim) {
// Check if the (empty block) is in the last properly closed block
if (parent.0.to(parent.1)).contains(span) {
err.span_label(
span,
"block is empty, you might have not meant to close it",
);
}
else {
err.span_label(
parent.0,
"this opening brace...",
);

err.span_label(
parent.1,
"...matches this closing brace",
);
}
}
else {
// Braces are added at the end, so the last element is the biggest block
if let Some(parent) = self.matching_block_spans.last() {
if let Some(span) = self.last_delim_empty_block_spans.remove(&delim) {
// Check if the (empty block) is in the last properly closed block
if (parent.0.to(parent.1)).contains(span) {
err.span_label(
parent.0,
"this opening brace...",
span,
"block is empty, you might have not meant to close it",
);
} else {
err.span_label(parent.0, "this opening brace...");

err.span_label(
parent.1,
"...matches this closing brace",
);
err.span_label(parent.1, "...matches this closing brace");
}
} else {
err.span_label(parent.0, "this opening brace...");

err.span_label(parent.1, "...matches this closing brace");
}
}

err.span_label(self.token.span, "unexpected closing delimiter");
Expand Down

0 comments on commit f96b92f

Please sign in to comment.