mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-28 07:30:57 +00:00
Auto merge of #7945 - Serial-ATA:issue-7934, r=flip1995
Fix ICE in undocumented_unsafe_blocks changelog: Fix ICE in [`undocumented_unsafe_blocks`] closes: #7934
This commit is contained in:
commit
6fcdf81939
3 changed files with 14 additions and 1 deletions
|
@ -149,6 +149,8 @@ impl UndocumentedUnsafeBlocks {
|
||||||
let lex_end = (between_span.hi().0 - source_file.start_pos.0) as usize;
|
let lex_end = (between_span.hi().0 - source_file.start_pos.0) as usize;
|
||||||
let src_str = source_file.src.as_ref()?[lex_start..lex_end].to_string();
|
let src_str = source_file.src.as_ref()?[lex_start..lex_end].to_string();
|
||||||
|
|
||||||
|
let source_start_pos = source_file.start_pos.0 as usize + lex_start;
|
||||||
|
|
||||||
let mut pos = 0;
|
let mut pos = 0;
|
||||||
let mut comment = false;
|
let mut comment = false;
|
||||||
|
|
||||||
|
@ -171,7 +173,7 @@ impl UndocumentedUnsafeBlocks {
|
||||||
if comment {
|
if comment {
|
||||||
// Get the line number of the "comment" (really wherever the trailing whitespace ended)
|
// Get the line number of the "comment" (really wherever the trailing whitespace ended)
|
||||||
let comment_line_num = source_file
|
let comment_line_num = source_file
|
||||||
.lookup_file_pos_with_col_display(BytePos((lex_start + pos).try_into().unwrap()))
|
.lookup_file_pos(BytePos((source_start_pos + pos).try_into().unwrap()))
|
||||||
.0;
|
.0;
|
||||||
// Find the block/local's line number
|
// Find the block/local's line number
|
||||||
let block_line_num = tcx.sess.source_map().lookup_char_pos(block_span.lo()).line;
|
let block_line_num = tcx.sess.source_map().lookup_char_pos(block_span.lo()).line;
|
||||||
|
|
4
tests/ui/crashes/auxiliary/ice-7934-aux.rs
Normal file
4
tests/ui/crashes/auxiliary/ice-7934-aux.rs
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
fn zero() {
|
||||||
|
// SAFETY:
|
||||||
|
unsafe { 0 };
|
||||||
|
}
|
7
tests/ui/crashes/ice-7934.rs
Normal file
7
tests/ui/crashes/ice-7934.rs
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
#![warn(clippy::undocumented_unsafe_blocks)]
|
||||||
|
#![allow(clippy::no_effect)]
|
||||||
|
|
||||||
|
#[path = "auxiliary/ice-7934-aux.rs"]
|
||||||
|
mod zero;
|
||||||
|
|
||||||
|
fn main() {}
|
Loading…
Reference in a new issue