Skip to content
Merged
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
2 changes: 2 additions & 0 deletions examples/big_struct_in_place.rs
Original file line number Diff line number Diff line change
@@ -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
Expand Down
6 changes: 6 additions & 0 deletions internal/src/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}})
}
Expand Down
18 changes: 12 additions & 6 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1147,9 +1147,12 @@ pub const unsafe fn cast_pin_init<T, U, E>(init: impl PinInit<T, E>) -> 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::<T>())) };
// 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
}

Expand All @@ -1163,9 +1166,12 @@ pub const unsafe fn cast_init<T, U, E>(init: impl Init<T, E>) -> impl Init<U, E>
// 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::<T>())) };
// 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
}

Expand Down
1 change: 1 addition & 0 deletions tests/default_error.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#![allow(dead_code)]
#![cfg_attr(not(RUSTC_LINT_REASONS_IS_STABLE), feature(lint_reasons))]

use pin_init::{init, Init};

Expand Down
5 changes: 4 additions & 1 deletion tests/ui/expand/no_field_access.expanded.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
};
}
5 changes: 4 additions & 1 deletion tests/ui/expand/simple-init.expanded.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
};
}
2 changes: 2 additions & 0 deletions tests/underscore.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![cfg_attr(not(RUSTC_LINT_REASONS_IS_STABLE), feature(lint_reasons))]

use pin_init::{init, Init};

pub struct Foo {
Expand Down