Fix ICE on undocumented_unsafe_blocks

This commit is contained in:
Takayuki Nakata 2021-11-17 22:35:01 +09:00
parent 83ad51108b
commit 3f3d7c2005
3 changed files with 19 additions and 3 deletions

View File

@ -137,10 +137,10 @@ impl UndocumentedUnsafeBlocks {
let between_span = if block_span.from_expansion() {
self.macro_expansion = true;
enclosing_scope_span.with_hi(block_span.hi())
enclosing_scope_span.with_hi(block_span.hi()).source_callsite()
} else {
self.macro_expansion = false;
enclosing_scope_span.to(block_span)
enclosing_scope_span.to(block_span).source_callsite()
};
let file_name = source_map.span_to_filename(between_span);

View File

@ -284,4 +284,8 @@ fn interference() {
unsafe {};
}
pub fn print_binary_tree() {
println!("{}", unsafe { String::from_utf8_unchecked(vec![]) });
}
fn main() {}

View File

@ -155,5 +155,17 @@ LL ~ // Safety: ...
LL ~ unsafe {};
|
error: aborting due to 13 previous errors
error: unsafe block missing a safety comment
--> $DIR/undocumented_unsafe_blocks.rs:288:20
|
LL | println!("{}", unsafe { String::from_utf8_unchecked(vec![]) });
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
help: consider adding a safety comment
|
LL ~ println!("{}", // Safety: ...
LL ~ unsafe { String::from_utf8_unchecked(vec![]) });
|
error: aborting due to 14 previous errors