mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2026-08-09 06:14:34 +02:00
Following the kernel minimum version bump in commit f32fb9c58a ("rust:
bump Rust minimum supported version to 1.85.0 (Debian Trixie)"), bump
pin-init's minimum Rust version to 1.82.
This removes the `lint_reasons` feature which is stabilized in 1.81 and the
`raw_ref_ops` and `new_uninit` features which are stabilized in 1.82.
Given we do not use any features that are stabilized in 1.82..=1.85 range,
and pin-init crate is useful for other projects which may have their own
MSRV requirements, the minimum version is not straightly bumped to 1.85.
Reviewed-by: Benno Lossin <lossin@kernel.org>
Link: https://patch.msgid.link/20260428-pin-init-sync-v1-2-07f9bd3859fb@garyguo.net
Signed-off-by: Gary Guo <gary@garyguo.net>
44 lines
935 B
Rust
44 lines
935 B
Rust
// SPDX-License-Identifier: Apache-2.0 OR MIT
|
|
|
|
use pin_init::*;
|
|
|
|
// Struct with size over 1GiB
|
|
#[derive(Debug)]
|
|
#[allow(dead_code)]
|
|
pub struct BigStruct {
|
|
buf: [u8; 1024 * 1024 * 1024],
|
|
a: u64,
|
|
b: u64,
|
|
c: u64,
|
|
d: u64,
|
|
managed_buf: ManagedBuf,
|
|
}
|
|
|
|
#[derive(Debug)]
|
|
pub struct ManagedBuf {
|
|
buf: [u8; 1024 * 1024],
|
|
}
|
|
|
|
impl ManagedBuf {
|
|
pub fn new() -> impl Init<Self> {
|
|
init!(ManagedBuf { buf <- init_zeroed() })
|
|
}
|
|
}
|
|
|
|
fn main() {
|
|
#[cfg(any(feature = "std", feature = "alloc"))]
|
|
{
|
|
// we want to initialize the struct in-place, otherwise we would get a stackoverflow
|
|
let buf: Box<BigStruct> = Box::init(init!(BigStruct {
|
|
buf <- init_zeroed(),
|
|
a: 7,
|
|
b: 186,
|
|
c: 7789,
|
|
d: 34,
|
|
managed_buf <- ManagedBuf::new(),
|
|
}))
|
|
.unwrap();
|
|
println!("{}", core::mem::size_of_val(&*buf));
|
|
}
|
|
}
|