diff --git a/clippy.toml b/clippy.toml new file mode 100644 index 0000000000..87b32d0ddf --- /dev/null +++ b/clippy.toml @@ -0,0 +1,6 @@ +# Copyright 2023 The Fuchsia Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +accept-comment-above-statement = true +accept-comment-above-attributes = true diff --git a/src/lib.rs b/src/lib.rs index 8eef8e6dde..4d8116a18a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -3626,11 +3626,6 @@ mod tests { let slc_field_ptr = addr_of_slice_field(ptr).as_ptr(); // SAFETY: Both `slc_field_ptr` and `ptr` are pointers to // the same valid Rust object. - // - // TODO(https://github.com/rust-lang/rust-clippy/issues/11534): - // Remove this `allow` once Clippy recognizes this block as - // having a safety comment. - #[allow(clippy::undocumented_unsafe_blocks)] let offset: usize = unsafe { slc_field_ptr.byte_offset_from(ptr.as_ptr()).try_into().unwrap() }; assert_eq!(offset, args.offset); diff --git a/src/wrappers.rs b/src/wrappers.rs index a0e6ac70ed..b787329d33 100644 --- a/src/wrappers.rs +++ b/src/wrappers.rs @@ -268,17 +268,13 @@ impl Unalign { impl Drop for WriteBackOnDrop { fn drop(&mut self) { - // SAFETY: See inline comments. - unsafe { - // SAFETY: We never use `copy` again as required by - // `ManuallyDrop::take`. - let copy = ManuallyDrop::take(&mut self.copy); - // SAFETY: `slf` is the raw pointer value of `self`. We know - // it is valid for writes and properly aligned because - // `self` is a mutable reference, which guarantees both of - // these properties. - ptr::write(self.slf, Unalign::new(copy)); - } + // SAFETY: We never use `copy` again as required by + // `ManuallyDrop::take`. + let copy = unsafe { ManuallyDrop::take(&mut self.copy) }; + // SAFETY: `slf` is the raw pointer value of `self`. We know it + // is valid for writes and properly aligned because `self` is a + // mutable reference, which guarantees both of these properties. + unsafe { ptr::write(self.slf, Unalign::new(copy)) }; } }