Skip to content

Commit c4efe2a

Browse files
bonziniBennoLossin
authored andcommitted
examples, tests: prepare to enable clippy::undocumented_unsafe_blocks lint
Signed-off-by: Paolo Bonzini <[email protected]>
1 parent 9826e0c commit c4efe2a

File tree

7 files changed

+8
-1
lines changed

7 files changed

+8
-1
lines changed

examples/linked_list.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#![allow(clippy::undocumented_unsafe_blocks)]
12
#![cfg_attr(feature = "alloc", feature(allocator_api))]
23

34
use core::{

examples/mutex.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#![allow(clippy::undocumented_unsafe_blocks)]
12
#![cfg_attr(feature = "alloc", feature(allocator_api))]
23

34
use core::{

examples/pthread_mutex.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// inspired by https://github.com/nbdd0121/pin-init/blob/trunk/examples/pthread_mutex.rs
2+
#![allow(clippy::undocumented_unsafe_blocks)]
23
#![cfg_attr(feature = "alloc", feature(allocator_api))]
34
#[cfg(not(windows))]
45
mod pthread_mtx {

examples/static_init.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#![allow(clippy::undocumented_unsafe_blocks)]
12
#![cfg_attr(feature = "alloc", feature(allocator_api))]
23

34
use core::{

tests/many_generics.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ where
2222
T: Bar<'b, 1>,
2323
{
2424
fn drop(self: Pin<&mut Self>) {
25+
// SAFETY: we do not move out of `self`
2526
let me = unsafe { Pin::get_unchecked_mut(self) };
2627
for t in &mut *me.r {
2728
Bar::<'a, 1>::bar(*t);

tests/ring_buf.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#![allow(clippy::undocumented_unsafe_blocks)]
12
#![cfg_attr(feature = "alloc", feature(allocator_api))]
23

34
use core::{

tests/zeroing.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ impl Foo {
1919
pin_init!(&this in Self {
2020
marks: {
2121
let ptr = this.as_ptr();
22-
let ptr = unsafe { addr_of_mut!((*ptr).buf)}.cast::<u8>();
22+
// SAFETY: project from the NonNull<Foo> to the buf field
23+
let ptr = unsafe { addr_of_mut!((*ptr).buf) }.cast::<u8>();
2324
[ptr; MARKS]},
2425
..Zeroable::zeroed()
2526
})

0 commit comments

Comments
 (0)