Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
a87b44d
Always inline `mem::{size_of,align_of}` in debug builds
tesuji Oct 2, 2019
3b0fd82
Disable Go and OCaml bindings when building LLVM
tmiasko Oct 8, 2019
e6ce3ef
Collect occurrences of for mismatched braces diagnostic
XiangQingW Oct 13, 2019
888d0ba
Collect occurrences of for mismatched braces diagnostic
XiangQingW Oct 13, 2019
fe819a0
Collect occurrences of for mismatched braces diagnostic
XiangQingW Oct 13, 2019
70b136d
Use a `BitSet` in `LexicalResolver::iterate_until_fixed_point()`.
nnethercote Oct 15, 2019
d51fee0
Inline and remove `iterate_until_fixed_point()`.
nnethercote Oct 16, 2019
42c0236
Use a sharded dep node to dep node index map
Zoxc Jun 13, 2019
c716be6
show up some extra info when t!() fails
Oct 17, 2019
d1db077
Add long error explanation for E0575
GuillaumeGomez Oct 12, 2019
21d9258
Update ui tests
GuillaumeGomez Oct 12, 2019
83e97c6
properly document panics in div_euclid and rem_euclid
tspiteri Oct 17, 2019
4cd9276
Add long error explanation for E0584
GuillaumeGomez Oct 17, 2019
f647c06
Update ui tests
GuillaumeGomez Oct 17, 2019
71b0049
Plugins deprecation: don’t suggest simply removing the attribute
SimonSapin Oct 17, 2019
a4d9492
add option to ping llvm ice-breakers to triagebot
nikomatsakis Oct 17, 2019
5fe88ab
save-analysis: Nest tables when processing impl items
Xanewok Oct 17, 2019
ad6ce46
save-analysis: Add a relevant test case
Xanewok Oct 17, 2019
4e6efe4
reorder fmt docs for more clarity
RalfJung Oct 17, 2019
5487994
Update triagebot.toml
nikomatsakis Oct 17, 2019
c0b7e76
example for padding any format
RalfJung Oct 17, 2019
c9b27d1
doc: make BitSet intro more short
tshepang Oct 17, 2019
cd9e444
rustc: arena-allocate the slice in `ty::GenericsPredicate`, not the w…
eddyb Oct 18, 2019
5de9cb0
super_ty on MutVisitor is empty so avoid the call
spastorino Oct 7, 2019
e069e9c
Prepare promote_consts MutVisitor to have projections interned
spastorino Oct 7, 2019
591cc9a
Prepare simplify MutVisitor to have projections interned
spastorino Oct 7, 2019
bb7d6d1
Prepare renumber MutVisitor to have projections interned
spastorino Oct 7, 2019
e3e9951
Prepare inline MutVisitor to have projections interned
spastorino Oct 7, 2019
0fc063f
Prepare generator MutVisitor to have projections interned
spastorino Oct 7, 2019
39c9ed3
Prepare erase_regions MutVisitor to have projections interned
spastorino Oct 7, 2019
2b2e35b
Prepare def_use MutVisitor to have projections interned
spastorino Oct 8, 2019
4f2a110
Remove unneeded callback and just use the new_local value
spastorino Oct 8, 2019
7fa3425
Setup a different visit place set of methods for mutable and immutabl…
spastorino Oct 8, 2019
d53fc9c
Add process_* place hooks to improve code reutilization
spastorino Oct 8, 2019
d0eaf60
Remove two no-op `into()` calls.
nnethercote Oct 15, 2019
a6eef29
Make `TokenStream::from_iter` less general and more efficient.
nnethercote Oct 13, 2019
212ae58
Change `Lit::tokens()` to `Lit::token_tree()`.
nnethercote Oct 14, 2019
e4ec4a6
Change `MetaItem::tokens()` to `MetaItem::token_trees_and_joints()`.
nnethercote Oct 14, 2019
769e75b
Fix left/right shift typo in wrapping rotate docs
t-rapp Oct 18, 2019
9617014
Clarify diagnostics when using `~` as a unary op
JohnTitor Oct 18, 2019
4834996
Use Cow to handle modifications of projection in preparation for inte…
spastorino Oct 9, 2019
7167a59
Rollup merge of #65016 - lzutao:inline-mem-constfn, r=oli-obk
tmandry Oct 18, 2019
d2bea3c
Rollup merge of #65197 - spastorino:place-mut-visitor-adjusts2, r=oli…
tmandry Oct 18, 2019
fdef437
Rollup merge of #65201 - tmiasko:no-bindings, r=rkruppe
tmandry Oct 18, 2019
bb53fed
Rollup merge of #65334 - GuillaumeGomez:long-err-explanation-E0575, r…
tmandry Oct 18, 2019
8f8a23f
Rollup merge of #65364 - XiangQingW:master, r=estebank
tmandry Oct 18, 2019
f5f5c9e
Rollup merge of #65455 - nnethercote:avoid-unnecessary-TokenTree-to-T…
tmandry Oct 18, 2019
05ab63e
Rollup merge of #65472 - Zoxc:sharded-dep-graph-2, r=nikomatsakis
tmandry Oct 18, 2019
c6bb960
Rollup merge of #65480 - nnethercote:rm-iterate_until_fixed_size, r=n…
tmandry Oct 18, 2019
e27e39b
Rollup merge of #65493 - GuillaumeGomez:long-err-explanation-E0584, r…
tmandry Oct 18, 2019
ea5a184
Rollup merge of #65496 - tspiteri:euc-div-panic, r=KodrAus
tmandry Oct 18, 2019
64bf0ca
Rollup merge of #65498 - SimonSapin:plugin-help, r=Centril
tmandry Oct 18, 2019
9fc8d8e
Rollup merge of #65508 - rust-lang:llvm-icebreakers-ping-1, r=simulacrum
tmandry Oct 18, 2019
156a55e
Rollup merge of #65511 - Xanewok:sa-nest-in-impls, r=pnkfelix
tmandry Oct 18, 2019
5948961
Rollup merge of #65513 - RalfJung:fmt, r=Mark-Simulacrum
tmandry Oct 18, 2019
138ff4a
Rollup merge of #65532 - tshepang:shorten-intro, r=Dylan-DPC
tmandry Oct 18, 2019
bc85061
Rollup merge of #65535 - eddyb:sliced-predicates, r=nikomatsakis
tmandry Oct 18, 2019
37cbdf3
Rollup merge of #65540 - guanqun:extend-t-macro, r=nikomatsakis
tmandry Oct 18, 2019
edc42a9
Rollup merge of #65549 - t-rapp:tr-wrapping-rotate-docs, r=jonas-schi…
tmandry Oct 18, 2019
3850408
Rollup merge of #65552 - JohnTitor:use-bitwise-not, r=Dylan-DPC
tmandry Oct 18, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Collect occurrences of for mismatched braces diagnostic
Change-Id: I20ba0b62308370ee961141fa1aefc4b9c9f0cb3a
  • Loading branch information
XiangQingW committed Oct 13, 2019
commit e6ce3ef80aad6df7e9971d126bb22619ab34927e
18 changes: 16 additions & 2 deletions src/libsyntax/parse/lexer/tokentrees.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use rustc_data_structures::fx::FxHashMap;
use syntax_pos::Span;

use crate::print::pprust::token_to_string;
Expand All @@ -16,6 +17,7 @@ impl<'a> StringReader<'a> {
unmatched_braces: Vec::new(),
matching_delim_spans: Vec::new(),
last_unclosed_found_span: None,
last_delim_empty_block_spans: FxHashMap::default()
};
let res = tt_reader.parse_all_token_trees();
(res, tt_reader.unmatched_braces)
Expand All @@ -34,6 +36,7 @@ struct TokenTreesReader<'a> {
/// Used only for error recovery when arriving to EOF with mismatched braces.
matching_delim_spans: Vec<(token::DelimToken, Span, Span)>,
last_unclosed_found_span: Option<Span>,
last_delim_empty_block_spans: FxHashMap<token::DelimToken, Span>
}

impl<'a> TokenTreesReader<'a> {
Expand Down Expand Up @@ -121,13 +124,20 @@ impl<'a> TokenTreesReader<'a> {
// Correct delimiter.
token::CloseDelim(d) if d == delim => {
let (open_brace, open_brace_span) = self.open_braces.pop().unwrap();
let close_brace_span = self.token.span;

if close_brace_span.lo() == open_brace_span.hi() {
let empty_block_span = open_brace_span.to(close_brace_span);
self.last_delim_empty_block_spans.insert(delim, empty_block_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.token.span),
(open_brace, open_brace_span, close_brace_span),
);
}
// Parse the close delimiter.
Expand Down Expand Up @@ -193,13 +203,17 @@ impl<'a> TokenTreesReader<'a> {
tts.into()
).into())
},
token::CloseDelim(_) => {
token::CloseDelim(delim) => {
// An unexpected closing delimiter (i.e., there is no
// matching opening delimiter).
let token_str = token_to_string(&self.token);
let msg = format!("unexpected close delimiter: `{}`", token_str);
let mut err = self.string_reader.sess.span_diagnostic
.struct_span_err(self.token.span, &msg);

if let Some(span) = self.last_delim_empty_block_spans.remove(&delim) {
err.span_label(span, "this block is empty, you might have not meant to close it");
}
err.span_label(self.token.span, "unexpected close delimiter");
Err(err)
},
Expand Down
2 changes: 1 addition & 1 deletion src/libsyntax/parse/token.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ pub enum BinOpToken {
}

/// A delimiter token.
#[derive(Clone, PartialEq, RustcEncodable, RustcDecodable, Hash, Debug, Copy)]
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug, Copy)]
pub enum DelimToken {
/// A round parenthesis (i.e., `(` or `)`).
Paren,
Expand Down
3 changes: 3 additions & 0 deletions src/test/ui/parser/mismatched-delim-brace-empty-block.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
fn main() {}
let _ = ();
} //~ ERROR unexpected close delimiter
11 changes: 11 additions & 0 deletions src/test/ui/parser/mismatched-delim-brace-empty-block.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
error: unexpected close delimiter: `}`
--> $DIR/mismatched-delim-brace-empty-block.rs:3:1
|
LL | fn main() {}
| -- this block is empty, you might have not meant to close it
LL | let _ = ();
LL | }
| ^ unexpected close delimiter

error: aborting due to previous error