Skip to content

Commit c28bfe7

Browse files
committed
rust: enable clippy::unnecessary_safety_comment lint
In Rust 1.67.0, Clippy added the `unnecessary_safety_comment` lint [1], which is the "inverse" of `undocumented_unsafe_blocks`: it finds places where safe code has a `// SAFETY` comment attached. The lint currently finds 3 places where we had such mistakes, thus it seems already quite useful. Thus clean those and enable it. Link: https://rust-lang.github.io/rust-clippy/master/index.html#/unnecessary_safety_comment [1] Reviewed-by: Alice Ryhl <[email protected]> Reviewed-by: Trevor Gross <[email protected]> Reviewed-by: Vincenzo Palazzo <[email protected]> Tested-by: Gary Guo <[email protected]> Reviewed-by: Gary Guo <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Miguel Ojeda <[email protected]>
1 parent db4f72c commit c28bfe7

File tree

3 files changed

+4
-3
lines changed

3 files changed

+4
-3
lines changed

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -458,6 +458,7 @@ export rust_common_flags := --edition=2021 \
458458
-Wclippy::needless_continue \
459459
-Wclippy::no_mangle_with_rust_abi \
460460
-Wclippy::undocumented_unsafe_blocks \
461+
-Wclippy::unnecessary_safety_comment \
461462
-Wrustdoc::missing_crate_level_docs
462463

463464
KBUILD_HOSTCFLAGS := $(KBUILD_USERHOSTCFLAGS) $(HOST_LFS_CFLAGS) \

rust/kernel/sync/arc.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ impl<T: 'static> ForeignOwnable for Arc<T> {
341341
}
342342

343343
unsafe fn borrow<'a>(ptr: *const core::ffi::c_void) -> ArcBorrow<'a, T> {
344-
// SAFETY: By the safety requirement of this function, we know that `ptr` came from
344+
// By the safety requirement of this function, we know that `ptr` came from
345345
// a previous call to `Arc::into_foreign`.
346346
let inner = NonNull::new(ptr as *mut ArcInner<T>).unwrap();
347347

rust/kernel/workqueue.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -526,7 +526,7 @@ where
526526
T: HasWork<T, ID>,
527527
{
528528
unsafe extern "C" fn run(ptr: *mut bindings::work_struct) {
529-
// SAFETY: The `__enqueue` method always uses a `work_struct` stored in a `Work<T, ID>`.
529+
// The `__enqueue` method always uses a `work_struct` stored in a `Work<T, ID>`.
530530
let ptr = ptr as *mut Work<T, ID>;
531531
// SAFETY: This computes the pointer that `__enqueue` got from `Arc::into_raw`.
532532
let ptr = unsafe { T::work_container_of(ptr) };
@@ -573,7 +573,7 @@ where
573573
T: HasWork<T, ID>,
574574
{
575575
unsafe extern "C" fn run(ptr: *mut bindings::work_struct) {
576-
// SAFETY: The `__enqueue` method always uses a `work_struct` stored in a `Work<T, ID>`.
576+
// The `__enqueue` method always uses a `work_struct` stored in a `Work<T, ID>`.
577577
let ptr = ptr as *mut Work<T, ID>;
578578
// SAFETY: This computes the pointer that `__enqueue` got from `Arc::into_raw`.
579579
let ptr = unsafe { T::work_container_of(ptr) };

0 commit comments

Comments
 (0)