mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-11 07:34:18 +00:00
Fix ICE in undocumented_unsafe_blocks
This commit is contained in:
parent
73c026b73f
commit
35bf041c21
3 changed files with 19 additions and 2 deletions
|
@ -145,8 +145,9 @@ impl UndocumentedUnsafeBlocks {
|
|||
let file_name = source_map.span_to_filename(between_span);
|
||||
let source_file = source_map.get_source_file(&file_name)?;
|
||||
|
||||
let lex_start = (between_span.lo().0 + 1) as usize;
|
||||
let src_str = source_file.src.as_ref()?[lex_start..between_span.hi().0 as usize].to_string();
|
||||
let lex_start = (between_span.lo().0 - source_file.start_pos.0 + 1) 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 mut pos = 0;
|
||||
let mut comment = false;
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
#![warn(clippy::undocumented_unsafe_blocks)]
|
||||
#![allow(clippy::no_effect)]
|
||||
|
||||
#[path = "auxiliary/ice-7868-aux.rs"]
|
||||
mod zero;
|
||||
|
|
15
tests/ui/crashes/ice-7868.stderr
Normal file
15
tests/ui/crashes/ice-7868.stderr
Normal file
|
@ -0,0 +1,15 @@
|
|||
error: unsafe block missing a safety comment
|
||||
--> $DIR/auxiliary/ice-7868-aux.rs:2:5
|
||||
|
|
||||
LL | unsafe { 0 };
|
||||
| ^^^^^^^^^^^^
|
||||
|
|
||||
= note: `-D clippy::undocumented-unsafe-blocks` implied by `-D warnings`
|
||||
help: consider adding a safety comment
|
||||
|
|
||||
LL ~ // Safety: ...
|
||||
LL ~ unsafe { 0 };
|
||||
|
|
||||
|
||||
error: aborting due to previous error
|
||||
|
Loading…
Reference in a new issue