Auto merge of #7988 - giraffate:fix_ice_on_undocumented_unsafe_blocks, r=flip1995

Fix ICE on `undocumented_unsafe_blocks`

fix https://github.com/rust-lang/rust-clippy/issues/7979

changelog: Fix ICE on `undocumented_unsafe_blocks`
This commit is contained in:
bors 2021-11-17 15:24:07 +00:00
commit d550e5f5e6
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