Addressing reviewer comments
This commit is contained in:
parent
520228b377
commit
e2e6a02445
@ -696,7 +696,7 @@ Minimum chars an ident can have, anything below or equal to this will be linted.
|
|||||||
|
|
||||||
|
|
||||||
## `accept-comment-above-statement`
|
## `accept-comment-above-statement`
|
||||||
Whether to accept a safety comment to be placed above the statement containing the `usafe` block
|
Whether to accept a safety comment to be placed above the statement containing the `unsafe` block
|
||||||
|
|
||||||
**Default Value:** `false` (`bool`)
|
**Default Value:** `false` (`bool`)
|
||||||
|
|
||||||
|
@ -580,7 +580,14 @@ fn get_body_search_span(cx: &LateContext<'_>) -> Option<Span> {
|
|||||||
for (_, node) in map.parent_iter(body.hir_id) {
|
for (_, node) in map.parent_iter(body.hir_id) {
|
||||||
match node {
|
match node {
|
||||||
Node::Expr(e) => span = e.span,
|
Node::Expr(e) => span = e.span,
|
||||||
Node::Block(_) | Node::Arm(_) | Node::Stmt(_) | Node::Local(_) => (),
|
Node::Block(_)
|
||||||
|
| Node::Arm(_)
|
||||||
|
| Node::Stmt(_)
|
||||||
|
| Node::Local(_)
|
||||||
|
| Node::Item(hir::Item {
|
||||||
|
kind: hir::ItemKind::Const(..) | ItemKind::Static(..),
|
||||||
|
..
|
||||||
|
}) => (),
|
||||||
_ => break,
|
_ => break,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -540,7 +540,7 @@ define_Conf! {
|
|||||||
(min_ident_chars_threshold: u64 = 1),
|
(min_ident_chars_threshold: u64 = 1),
|
||||||
/// Lint: UNDOCUMENTED_UNSAFE_BLOCKS.
|
/// Lint: UNDOCUMENTED_UNSAFE_BLOCKS.
|
||||||
///
|
///
|
||||||
/// Whether to accept a safety comment to be placed above the statement containing the `usafe` block
|
/// Whether to accept a safety comment to be placed above the statement containing the `unsafe` block
|
||||||
(accept_comment_above_statement: bool = false),
|
(accept_comment_above_statement: bool = false),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,8 +5,20 @@ fn main() {
|
|||||||
// Safety: A safety comment
|
// Safety: A safety comment
|
||||||
let _some_variable_with_a_very_long_name_to_break_the_line =
|
let _some_variable_with_a_very_long_name_to_break_the_line =
|
||||||
unsafe { a_function_with_a_very_long_name_to_break_the_line() };
|
unsafe { a_function_with_a_very_long_name_to_break_the_line() };
|
||||||
|
|
||||||
|
// Safety: Another safety comment
|
||||||
|
const _SOME_CONST_WITH_A_VERY_LONG_NAME_TO_BREAK_THE_LINE: u32 =
|
||||||
|
unsafe { a_const_function_with_a_very_long_name_to_break_the_line() };
|
||||||
|
|
||||||
|
// Safety: Yet another safety comment
|
||||||
|
static _SOME_STATIC_WITH_A_VERY_LONG_NAME_TO_BREAK_THE_LINE: u32 =
|
||||||
|
unsafe { a_const_function_with_a_very_long_name_to_break_the_line() };
|
||||||
}
|
}
|
||||||
|
|
||||||
pub unsafe fn a_function_with_a_very_long_name_to_break_the_line() -> u32 {
|
pub unsafe fn a_function_with_a_very_long_name_to_break_the_line() -> u32 {
|
||||||
1
|
1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub const unsafe fn a_const_function_with_a_very_long_name_to_break_the_line() -> u32 {
|
||||||
|
2
|
||||||
|
}
|
||||||
|
@ -513,10 +513,22 @@ pub unsafe fn a_function_with_a_very_long_name_to_break_the_line() -> u32 {
|
|||||||
1
|
1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub const unsafe fn a_const_function_with_a_very_long_name_to_break_the_line() -> u32 {
|
||||||
|
2
|
||||||
|
}
|
||||||
|
|
||||||
fn issue_10832() {
|
fn issue_10832() {
|
||||||
// Safety: A safety comment. But it will warn anyways
|
// Safety: A safety comment. But it will warn anyways
|
||||||
let _some_variable_with_a_very_long_name_to_break_the_line =
|
let _some_variable_with_a_very_long_name_to_break_the_line =
|
||||||
unsafe { a_function_with_a_very_long_name_to_break_the_line() };
|
unsafe { a_function_with_a_very_long_name_to_break_the_line() };
|
||||||
|
|
||||||
|
// Safety: Another safety comment. But it will warn anyways
|
||||||
|
const _SOME_CONST_WITH_A_VERY_LONG_NAME_TO_BREAK_THE_LINE: u32 =
|
||||||
|
unsafe { a_const_function_with_a_very_long_name_to_break_the_line() };
|
||||||
|
|
||||||
|
// Safety: Yet another safety comment. But it will warn anyways
|
||||||
|
static _SOME_STATIC_WITH_A_VERY_LONG_NAME_TO_BREAK_THE_LINE: u32 =
|
||||||
|
unsafe { a_const_function_with_a_very_long_name_to_break_the_line() };
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {}
|
fn main() {}
|
||||||
|
@ -319,12 +319,28 @@ LL | let bar = unsafe {};
|
|||||||
= help: consider adding a safety comment on the preceding line
|
= help: consider adding a safety comment on the preceding line
|
||||||
|
|
||||||
error: unsafe block missing a safety comment
|
error: unsafe block missing a safety comment
|
||||||
--> $DIR/undocumented_unsafe_blocks.rs:519:9
|
--> $DIR/undocumented_unsafe_blocks.rs:523:9
|
||||||
|
|
|
|
||||||
LL | unsafe { a_function_with_a_very_long_name_to_break_the_line() };
|
LL | unsafe { a_function_with_a_very_long_name_to_break_the_line() };
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
|
|
||||||
= help: consider adding a safety comment on the preceding line
|
= help: consider adding a safety comment on the preceding line
|
||||||
|
|
||||||
error: aborting due to 37 previous errors
|
error: unsafe block missing a safety comment
|
||||||
|
--> $DIR/undocumented_unsafe_blocks.rs:527:9
|
||||||
|
|
|
||||||
|
LL | unsafe { a_const_function_with_a_very_long_name_to_break_the_line() };
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
|
||||||
|
= help: consider adding a safety comment on the preceding line
|
||||||
|
|
||||||
|
error: unsafe block missing a safety comment
|
||||||
|
--> $DIR/undocumented_unsafe_blocks.rs:531:9
|
||||||
|
|
|
||||||
|
LL | unsafe { a_const_function_with_a_very_long_name_to_break_the_line() };
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
|
||||||
|
= help: consider adding a safety comment on the preceding line
|
||||||
|
|
||||||
|
error: aborting due to 39 previous errors
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user