diff --git a/examples/big_struct_in_place.rs b/examples/big_struct_in_place.rs index c0513992..0792d927 100644 --- a/examples/big_struct_in_place.rs +++ b/examples/big_struct_in_place.rs @@ -1,5 +1,7 @@ // SPDX-License-Identifier: Apache-2.0 OR MIT +#![cfg_attr(not(RUSTC_LINT_REASONS_IS_STABLE), feature(lint_reasons))] + use pin_init::*; // Struct with size over 1GiB diff --git a/internal/src/init.rs b/internal/src/init.rs index 42936f91..27bf9cfe 100644 --- a/internal/src/init.rs +++ b/internal/src/init.rs @@ -189,6 +189,12 @@ pub(crate) fn expand( }; // SAFETY: TODO let init = unsafe { ::pin_init::#init_from_closure::<_, #error>(init) }; + // FIXME: this let binding is required to avoid a compiler error (cycle when computing the + // opaque type returned by this function) before Rust 1.81. Remove after MSRV bump. + #[allow( + clippy::let_and_return, + reason = "some clippy versions warn about the let binding" + )] init }}) } diff --git a/src/lib.rs b/src/lib.rs index fe4c85ae..73177147 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1147,9 +1147,12 @@ pub const unsafe fn cast_pin_init(init: impl PinInit) -> impl Pin // SAFETY: initialization delegated to a valid initializer. Cast is valid by function safety // requirements. let res = unsafe { pin_init_from_closure(|ptr: *mut U| init.__pinned_init(ptr.cast::())) }; - // FIXME: remove the let statement once the nightly-MSRV allows it (1.78 otherwise encounters a - // cycle when computing the type returned by this function) - #[allow(clippy::let_and_return)] + // FIXME: this let binding is required to avoid a compiler error (cycle when computing the opaque + // type returned by this function) before Rust 1.81. Remove after MSRV bump. + #[allow( + clippy::let_and_return, + reason = "some clippy versions warn about the let binding" + )] res } @@ -1163,9 +1166,12 @@ pub const unsafe fn cast_init(init: impl Init) -> impl Init // SAFETY: initialization delegated to a valid initializer. Cast is valid by function safety // requirements. let res = unsafe { init_from_closure(|ptr: *mut U| init.__init(ptr.cast::())) }; - // FIXME: remove the let statement once the nightly-MSRV allows it (1.78 otherwise encounters a - // cycle when computing the type returned by this function) - #[allow(clippy::let_and_return)] + // FIXME: this let binding is required to avoid a compiler error (cycle when computing the opaque + // type returned by this function) before Rust 1.81. Remove after MSRV bump. + #[allow( + clippy::let_and_return, + reason = "some clippy versions warn about the let binding" + )] res } diff --git a/tests/default_error.rs b/tests/default_error.rs index dc357626..c2ca60d2 100644 --- a/tests/default_error.rs +++ b/tests/default_error.rs @@ -1,4 +1,5 @@ #![allow(dead_code)] +#![cfg_attr(not(RUSTC_LINT_REASONS_IS_STABLE), feature(lint_reasons))] use pin_init::{init, Init}; diff --git a/tests/ui/expand/no_field_access.expanded.rs b/tests/ui/expand/no_field_access.expanded.rs index 28542ac2..2b935432 100644 --- a/tests/ui/expand/no_field_access.expanded.rs +++ b/tests/ui/expand/no_field_access.expanded.rs @@ -68,6 +68,9 @@ fn main() { let init = unsafe { ::pin_init::init_from_closure::<_, ::core::convert::Infallible>(init) }; - init + #[allow( + clippy::let_and_return, + reason = "some clippy versions warn about the let binding" + )] init }; } diff --git a/tests/ui/expand/simple-init.expanded.rs b/tests/ui/expand/simple-init.expanded.rs index c050a449..822d84c8 100644 --- a/tests/ui/expand/simple-init.expanded.rs +++ b/tests/ui/expand/simple-init.expanded.rs @@ -30,6 +30,9 @@ fn main() { let init = unsafe { ::pin_init::init_from_closure::<_, ::core::convert::Infallible>(init) }; - init + #[allow( + clippy::let_and_return, + reason = "some clippy versions warn about the let binding" + )] init }; } diff --git a/tests/underscore.rs b/tests/underscore.rs index a55a238a..bdf7a9d0 100644 --- a/tests/underscore.rs +++ b/tests/underscore.rs @@ -1,3 +1,5 @@ +#![cfg_attr(not(RUSTC_LINT_REASONS_IS_STABLE), feature(lint_reasons))] + use pin_init::{init, Init}; pub struct Foo {