Skip to content

Rollup of 10 pull requests #96101

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

Closed
wants to merge 28 commits into from
Closed
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
d78e3e3
Add platform support document links to tier table
Michcioperz Mar 4, 2022
c1d5c2b
Add missing platform support docs to sidebar
Michcioperz Mar 4, 2022
9cfdb89
Only add codegen backend to dep info if -Zbinary-dep-depinfo is used
bjorn3 Feb 13, 2022
c681a88
Don't include invalid paths in the depinfo for builtin backends
bjorn3 Feb 13, 2022
147e5da
Add test
bjorn3 Mar 24, 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
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
9d319f3
update: actions/checkout@v2 to actions/checkout@v3
Gumichocopengin8 Apr 14, 2022
753d567
clarify doc(cfg) wording
euclio Apr 14, 2022
e30d6d9
make unaligned_references lint deny-by-default
RalfJung Mar 27, 2022
1a6c2ff
make unaligned_reference warning visible in future compat report
RalfJung Apr 15, 2022
4117e8c
test: add pop_first() pop_last() test cases for BTreeSet
Gumichocopengin8 Apr 15, 2022
e162602
test: add get_key_value() test cases for BTreeSet
Gumichocopengin8 Apr 15, 2022
3f2f4a3
test: add try_insert() test cases for BTreeSet
Gumichocopengin8 Apr 15, 2022
3f46ba6
chore: formatting
Gumichocopengin8 Apr 15, 2022
5181422
Update mdbook
ehuss Apr 15, 2022
7b8df43
Rollup merge of #93969 - bjorn3:codegen_backend_dep_info, r=pnkfelix
Dylan-DPC Apr 16, 2022
e292641
Rollup merge of #94605 - Michcioperz:patch-1, r=pnkfelix
Dylan-DPC Apr 16, 2022
a21f392
Rollup merge of #95372 - RalfJung:unaligned_references, r=oli-obk
Dylan-DPC Apr 16, 2022
ac01c91
Rollup merge of #95859 - rainy-me:unterminated-nested-block-comment, …
Dylan-DPC Apr 16, 2022
a30dbc2
Rollup merge of #96004 - JakobDegen:fix-validator-ice, r=petrochenkov
Dylan-DPC Apr 16, 2022
466107e
Rollup merge of #96035 - Gumichocopengin8:feature/update-github-actio…
Dylan-DPC Apr 16, 2022
f72689a
Rollup merge of #96050 - oli-obk:deaggregator_cleanup, r=RalfJung
Dylan-DPC Apr 16, 2022
10e8a2a
Rollup merge of #96059 - euclio:doc-cfg, r=manishearth,guillaumegomez
Dylan-DPC Apr 16, 2022
be42af6
Rollup merge of #96070 - Gumichocopengin8:test/btree-map, r=thomcc
Dylan-DPC Apr 16, 2022
45af788
Rollup merge of #96088 - ehuss:update-mdbook, r=Mark-Simulacrum
Dylan-DPC Apr 16, 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
60 changes: 50 additions & 10 deletions compiler/rustc_parse/src/lexer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,16 +182,7 @@ impl<'a> StringReader<'a> {
}
rustc_lexer::TokenKind::BlockComment { doc_style, terminated } => {
if !terminated {
let msg = match doc_style {
Some(_) => "unterminated block doc-comment",
None => "unterminated block comment",
};
let last_bpos = self.pos;
self.sess.span_diagnostic.span_fatal_with_code(
self.mk_sp(start, last_bpos),
msg,
error_code!(E0758),
);
self.report_unterminated_block_comment(start, doc_style);
}

// Skip non-doc comments
Expand Down Expand Up @@ -553,6 +544,55 @@ impl<'a> StringReader<'a> {
err.emit()
}

fn report_unterminated_block_comment(&self, start: BytePos, doc_style: Option<DocStyle>) {
let msg = match doc_style {
Some(_) => "unterminated block doc-comment",
None => "unterminated block comment",
};
let last_bpos = self.pos;
let mut err = self.sess.span_diagnostic.struct_span_fatal_with_code(
self.mk_sp(start, last_bpos),
msg,
error_code!(E0758),
);
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().peekable();

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),
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),
start + BytePos(nested_close_idx as u32 + 2),
),
"...and last nested comment terminates here.",
);
}

err.emit();
}

// RFC 3101 introduced the idea of (reserved) prefixes. As of Rust 2021,
// using a (unknown) prefix is an error. In earlier editions, however, they
// only result in a (allowed by default) lint, and are treated as regular
Expand Down
4 changes: 4 additions & 0 deletions src/test/ui/unterminated-nested-comment.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/* //~ ERROR E0758
/* */
/*
*/
21 changes: 21 additions & 0 deletions src/test/ui/unterminated-nested-comment.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
error[E0758]: unterminated block comment
--> $DIR/unterminated-nested-comment.rs:1:1
|
LL | /*
| ^-
| |
| _unterminated block comment
| |
LL | | /* */
LL | | /*
| | --
| | |
| | ...as last nested comment starts here, maybe you want to close this instead?
LL | | */
| |_--^
| |
| ...and last nested comment terminates here.

error: aborting due to previous error

For more information about this error, try `rustc --explain E0758`.