mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-27 15:11:30 +00:00
Addressing reviewer comments
This commit is contained in:
parent
520228b377
commit
e2e6a02445
6 changed files with 52 additions and 5 deletions
|
@ -696,7 +696,7 @@ Minimum chars an ident can have, anything below or equal to this will be linted.
|
|||
|
||||
|
||||
## `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`)
|
||||
|
||||
|
|
|
@ -580,7 +580,14 @@ fn get_body_search_span(cx: &LateContext<'_>) -> Option<Span> {
|
|||
for (_, node) in map.parent_iter(body.hir_id) {
|
||||
match node {
|
||||
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,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -540,7 +540,7 @@ define_Conf! {
|
|||
(min_ident_chars_threshold: u64 = 1),
|
||||
/// 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),
|
||||
}
|
||||
|
||||
|
|
|
@ -5,8 +5,20 @@ fn main() {
|
|||
// Safety: A safety comment
|
||||
let _some_variable_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 {
|
||||
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
|
||||
}
|
||||
|
||||
pub const unsafe fn a_const_function_with_a_very_long_name_to_break_the_line() -> u32 {
|
||||
2
|
||||
}
|
||||
|
||||
fn issue_10832() {
|
||||
// Safety: A safety comment. But it will warn anyways
|
||||
let _some_variable_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() {}
|
||||
|
|
|
@ -319,12 +319,28 @@ LL | let bar = unsafe {};
|
|||
= help: consider adding a safety comment on the preceding line
|
||||
|
||||
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() };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= 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…
Reference in a new issue