Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 9 pull requests #96063

Closed
wants to merge 21 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
21 commits
Select commit Hold shift click to select a range
5e76103
Reject `#[thread_local]` attribute on non-static items
tmiasko Mar 16, 2022
8c2353b
remove find_use_placement
kckeiks Mar 18, 2022
abf2b4c
Stabilize `derive_default_enum`
jhpratt Feb 28, 2022
a3dd654
Add documentation
jhpratt Mar 8, 2022
d5f3863
Consider lifetimes when comparing types for equality in MIR validator
JakobDegen Apr 13, 2022
4a0f8d5
improve diagnostics for unterminated nested block comment
yue4u Apr 13, 2022
849ede1
Update books
ehuss Apr 14, 2022
f6d9577
docs: add link from zip to unzip
beyarkay Apr 14, 2022
d73e328
Remove trailing whitespace
beyarkay Apr 14, 2022
7a35c0f
Use u32 instead of i32 for futexes.
m-ou-se Apr 14, 2022
1b7008d
refactor: change to use peekable
yue4u Apr 14, 2022
48029ab
Remove some now-dead code that was only relevant before deaggregation.
oli-obk Apr 14, 2022
5ab0306
Rollup merge of #94457 - jhpratt:stabilize-derive_default_enum, r=dav…
Dylan-DPC Apr 15, 2022
c149fec
Rollup merge of #95006 - tmiasko:thread-local-static, r=wesleywiser
Dylan-DPC Apr 15, 2022
5f525be
Rollup merge of #95194 - kckeiks:update-algo-in-find-use-placement, r…
Dylan-DPC Apr 15, 2022
d1b8125
Rollup merge of #95859 - rainy-me:unterminated-nested-block-comment, …
Dylan-DPC Apr 15, 2022
89dd3bf
Rollup merge of #96004 - JakobDegen:fix-validator-ice, r=petrochenkov
Dylan-DPC Apr 15, 2022
4ee5130
Rollup merge of #96032 - ehuss:update-books, r=ehuss
Dylan-DPC Apr 15, 2022
d5232f8
Rollup merge of #96038 - beyarkay:patch-1, r=m-ou-se
Dylan-DPC Apr 15, 2022
61a4193
Rollup merge of #96040 - m-ou-se:futex-u32, r=Amanieu
Dylan-DPC Apr 15, 2022
a024036
Rollup merge of #96050 - oli-obk:deaggregator_cleanup, r=RalfJung
Dylan-DPC Apr 15, 2022
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
refactor: change to use peekable
  • Loading branch information
yue4u committed Apr 14, 2022
commit 1b7008dc77e25049b04e5c3e31aecf4de00803e7
37 changes: 17 additions & 20 deletions compiler/rustc_parse/src/lexer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -557,39 557,36 @@ impl<'a> StringReader<'a> {
);
let mut nested_block_comment_open_idxs = vec![];
let mut last_nested_block_comment_idxs = None;
let mut content_chars = self.str_from(start).char_indices();
let mut content_chars = self.str_from(start).char_indices().peekable();

if let Some((_, mut last_char)) = content_chars.next() {
while let Some((idx, c)) = content_chars.next() {
match c {
'*' if last_char == '/' => {
nested_block_comment_open_idxs.push(idx);
}
'/' if last_char == '*' => {
last_nested_block_comment_idxs =
nested_block_comment_open_idxs.pop().map(|open_idx| (open_idx, idx));
}
_ => {}
};
last_char = c;
}
while let Some((idx, current_char)) = content_chars.next() {
match content_chars.peek() {
Some((_, '*')) if current_char == '/' => {
nested_block_comment_open_idxs.push(idx);
}
Some((_, '/')) if current_char == '*' => {
last_nested_block_comment_idxs =
nested_block_comment_open_idxs.pop().map(|open_idx| (open_idx, idx));
}
_ => {}
};
}

if let Some((nested_open_idx, nested_close_idx)) = last_nested_block_comment_idxs {
err.span_label(self.mk_sp(start, start BytePos(2)), msg)
.span_label(
self.mk_sp(
start BytePos(nested_open_idx as u32 - 1),
start BytePos(nested_open_idx as u32 1),
start BytePos(nested_open_idx as u32),
start BytePos(nested_open_idx as u32 2),
),
"...as last nested comment starts here, maybe you want to close this instead?",
)
.span_label(
self.mk_sp(
start BytePos(nested_close_idx as u32 - 1),
start BytePos(nested_close_idx as u32 1),
start BytePos(nested_close_idx as u32),
start BytePos(nested_close_idx as u32 2),
),
"...and last nested comment terminates here",
"...and last nested comment terminates here.",
);
}

Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/unterminated-nested-comment.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 14,7 @@ LL | | /*
LL | | */
| |_--^
| |
| ...and last nested comment terminates here
| ...and last nested comment terminates here.

error: aborting due to previous error

Expand Down