Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions examples/mutex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,17 +91,14 @@ impl<T> CMutex<T> {
pub fn lock(&self) -> Pin<CMutexGuard<'_, T>> {
let mut sguard = self.spin_lock.acquire();
if self.locked.get() {
stack_pin_init!(let wait_entry = WaitEntry::insert_new(&self.wait_list));
stack_pin_init!(let _wait_entry = WaitEntry::insert_new(&self.wait_list));
// println!("wait list length: {}", self.wait_list.size());
while self.locked.get() {
drop(sguard);
#[cfg(feature = "std")]
thread::park();
sguard = self.spin_lock.acquire();
}
// This does have an effect, as the ListHead inside wait_entry implements Drop!
#[expect(clippy::drop_non_drop)]
drop(wait_entry);
}
self.locked.set(true);
unsafe {
Expand Down
8 changes: 5 additions & 3 deletions internal/src/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -233,10 +233,12 @@ fn init_fields(
InitializerKind::Value { ident, .. } => ident,
InitializerKind::Init { ident, .. } => ident,
InitializerKind::Code { block, .. } => {
let stmt = &block.stmts;
res.extend(quote! {
#(#attrs)*
#[allow(unused_braces)]
#block
{
#(#stmt)*
}
});
continue;
}
Expand Down Expand Up @@ -334,7 +336,7 @@ fn make_field_check(
}),
};
quote! {
#[allow(unreachable_code, clippy::diverging_sub_expression)]
#[allow(unreachable_code)]
// We use unreachable code to perform field checks. They're still checked by the compiler.
// SAFETY: this code is never executed.
let _ = || unsafe {
Expand Down
3 changes: 0 additions & 3 deletions internal/src/pin_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -245,15 +245,13 @@ fn generate_drop_impl(ident: &Ident, generics: &Generics, args: Args) -> TokenSt
// `Drop`. Additionally we will implement this trait for the struct leading to a conflict,
// if it also implements `Drop`
trait MustNotImplDrop {}
#[expect(drop_bounds)]
impl<T: ::core::ops::Drop + ?::core::marker::Sized> MustNotImplDrop for T {}
impl #impl_generics MustNotImplDrop for #ident #ty_generics
#whr
{}
// We also take care to prevent users from writing a useless `PinnedDrop` implementation.
// They might implement `PinnedDrop` correctly for the struct, but forget to give
// `PinnedDrop` as the parameter to `#[pin_data]`.
#[expect(non_camel_case_types)]
trait UselessPinnedDropImpl_you_need_to_specify_PinnedDrop {}
impl<T: ::pin_init::PinnedDrop + ?::core::marker::Sized>
UselessPinnedDropImpl_you_need_to_specify_PinnedDrop for T {}
Expand Down Expand Up @@ -432,7 +430,6 @@ fn generate_the_pin_data(
{}

#[allow(dead_code)] // Some functions might never be used and private.
#[expect(clippy::missing_safety_doc)]
impl #impl_generics __ThePinData #ty_generics
#whr
{
Expand Down
7 changes: 0 additions & 7 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@
//! that you need to write `<-` instead of `:` for fields that you want to initialize in-place.
//!
//! ```rust
//! # #![expect(clippy::disallowed_names)]
//! # #![feature(allocator_api)]
//! # #[path = "../examples/mutex.rs"] mod mutex; use mutex::*;
//! # use core::pin::Pin;
Expand All @@ -94,7 +93,6 @@
//! (or just the stack) to actually initialize a `Foo`:
//!
//! ```rust
//! # #![expect(clippy::disallowed_names)]
//! # #![feature(allocator_api)]
//! # #[path = "../examples/mutex.rs"] mod mutex; use mutex::*;
//! # use core::{alloc::AllocError, pin::Pin};
Expand Down Expand Up @@ -456,7 +454,6 @@ pub use ::pin_init_internal::MaybeZeroable;
/// # Examples
///
/// ```rust
/// # #![expect(clippy::disallowed_names)]
/// # #![feature(allocator_api)]
/// # #[path = "../examples/mutex.rs"] mod mutex; use mutex::*;
/// # use pin_init::*;
Expand Down Expand Up @@ -508,7 +505,6 @@ macro_rules! stack_pin_init {
/// # Examples
///
/// ```rust
/// # #![expect(clippy::disallowed_names)]
/// # #![feature(allocator_api)]
/// # #[path = "../examples/error.rs"] mod error; use error::Error;
/// # #[path = "../examples/mutex.rs"] mod mutex; use mutex::*;
Expand All @@ -535,7 +531,6 @@ macro_rules! stack_pin_init {
/// ```
///
/// ```rust
/// # #![expect(clippy::disallowed_names)]
/// # #![feature(allocator_api)]
/// # #[path = "../examples/error.rs"] mod error; use error::Error;
/// # #[path = "../examples/mutex.rs"] mod mutex; use mutex::*;
Expand Down Expand Up @@ -658,7 +653,6 @@ macro_rules! stack_try_pin_init {
/// Users of `Foo` can now create it like this:
///
/// ```rust
/// # #![expect(clippy::disallowed_names)]
/// # use pin_init::*;
/// # use core::pin::Pin;
/// # #[pin_data]
Expand Down Expand Up @@ -1031,7 +1025,6 @@ pub unsafe trait Init<T: ?Sized, E = Infallible>: PinInit<T, E> {
/// # Examples
///
/// ```rust
/// # #![expect(clippy::disallowed_names)]
/// use pin_init::{init, init_zeroed, Init};
///
/// struct Foo {
Expand Down
1 change: 0 additions & 1 deletion tests/ui/expand/many_generics.expanded.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ const _: () = {
T: Bar<'a, 1>,
{}
#[allow(dead_code)]
#[expect(clippy::missing_safety_doc)]
impl<
'a,
'b: 'a,
Expand Down
3 changes: 0 additions & 3 deletions tests/ui/expand/pin-data.expanded.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ const _: () = {
}
impl ::core::marker::Copy for __ThePinData {}
#[allow(dead_code)]
#[expect(clippy::missing_safety_doc)]
impl __ThePinData {
/// Type inference helper function.
#[inline(always)]
Expand Down Expand Up @@ -111,10 +110,8 @@ const _: () = {
__Unpin<'__pin>: ::core::marker::Unpin,
{}
trait MustNotImplDrop {}
#[expect(drop_bounds)]
impl<T: ::core::ops::Drop + ?::core::marker::Sized> MustNotImplDrop for T {}
impl MustNotImplDrop for Foo {}
#[expect(non_camel_case_types)]
trait UselessPinnedDropImpl_you_need_to_specify_PinnedDrop {}
impl<
T: ::pin_init::PinnedDrop + ?::core::marker::Sized,
Expand Down
1 change: 0 additions & 1 deletion tests/ui/expand/pinned_drop.expanded.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ const _: () = {
}
impl ::core::marker::Copy for __ThePinData {}
#[allow(dead_code)]
#[expect(clippy::missing_safety_doc)]
impl __ThePinData {
/// Type inference helper function.
#[inline(always)]
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/expand/simple-init.expanded.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ fn main() {
_,
::core::convert::Infallible,
>(move |slot| {
#[allow(unreachable_code, clippy::diverging_sub_expression)]
#[allow(unreachable_code)]
let _ = || unsafe { ::core::ptr::write(slot, Foo {}) };
Ok(unsafe { ::pin_init::__internal::InitOk::new() })
});
Expand Down
Loading