mirror of
https://github.com/rust-lang/rust.git
synced 2026-04-27 18:57:42 +03:00
Wrap NonZero::new_unchecked call in the print_type_sizes test in a const
This commit is contained in:
@@ -55,7 +55,14 @@ pub struct NestedNonZero {
|
||||
|
||||
impl Default for NestedNonZero {
|
||||
fn default() -> Self {
|
||||
NestedNonZero { pre: 0, val: unsafe { NonZero::new_unchecked(1) }, post: 0 }
|
||||
// Ideally we'd call NonZero::new_unchecked, but this test is supposed
|
||||
// to be target-independent and NonZero::new_unchecked is #[track_caller]
|
||||
// (see #129658) so mentioning that function pulls in std::panic::Location
|
||||
// which contains a &str, whose layout is target-dependent.
|
||||
const ONE: NonZero<u32> = const {
|
||||
unsafe { std::mem::transmute(1u32) }
|
||||
};
|
||||
NestedNonZero { pre: 0, val: ONE, post: 0 }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,25 +1,3 @@
|
||||
print-type-size type: `std::fmt::Arguments<'_>`: 48 bytes, alignment: 8 bytes
|
||||
print-type-size field `.pieces`: 16 bytes
|
||||
print-type-size field `.args`: 16 bytes
|
||||
print-type-size field `.fmt`: 16 bytes
|
||||
print-type-size type: `std::panic::Location<'_>`: 24 bytes, alignment: 8 bytes
|
||||
print-type-size field `.file`: 16 bytes
|
||||
print-type-size field `.line`: 4 bytes
|
||||
print-type-size field `.col`: 4 bytes
|
||||
print-type-size type: `core::fmt::rt::Argument<'_>`: 16 bytes, alignment: 8 bytes
|
||||
print-type-size field `.ty`: 16 bytes
|
||||
print-type-size type: `core::fmt::rt::ArgumentType<'_>`: 16 bytes, alignment: 8 bytes
|
||||
print-type-size variant `Placeholder`: 16 bytes
|
||||
print-type-size field `.value`: 8 bytes
|
||||
print-type-size field `.formatter`: 8 bytes
|
||||
print-type-size field `._lifetime`: 0 bytes
|
||||
print-type-size variant `Count`: 10 bytes
|
||||
print-type-size padding: 8 bytes
|
||||
print-type-size field `.0`: 2 bytes, alignment: 2 bytes
|
||||
print-type-size type: `std::option::Option<&[core::fmt::rt::Placeholder]>`: 16 bytes, alignment: 8 bytes
|
||||
print-type-size variant `Some`: 16 bytes
|
||||
print-type-size field `.0`: 16 bytes
|
||||
print-type-size variant `None`: 0 bytes
|
||||
print-type-size type: `IndirectNonZero`: 12 bytes, alignment: 4 bytes
|
||||
print-type-size field `.nested`: 8 bytes
|
||||
print-type-size field `.post`: 2 bytes
|
||||
@@ -56,8 +34,6 @@ print-type-size field `.val`: 4 bytes
|
||||
print-type-size field `.post`: 2 bytes
|
||||
print-type-size field `.pre`: 1 bytes
|
||||
print-type-size end padding: 1 bytes
|
||||
print-type-size type: `std::ptr::NonNull<()>`: 8 bytes, alignment: 8 bytes
|
||||
print-type-size field `.pointer`: 8 bytes
|
||||
print-type-size type: `Enum4<(), char, (), ()>`: 4 bytes, alignment: 4 bytes
|
||||
print-type-size variant `Two`: 4 bytes
|
||||
print-type-size field `.0`: 4 bytes
|
||||
@@ -96,10 +72,6 @@ print-type-size type: `core::num::niche_types::NonZeroU32Inner`: 4 bytes, alignm
|
||||
print-type-size field `.0`: 4 bytes
|
||||
print-type-size type: `std::num::NonZero<u32>`: 4 bytes, alignment: 4 bytes
|
||||
print-type-size field `.0`: 4 bytes
|
||||
print-type-size type: `std::option::Option<std::num::NonZero<u32>>`: 4 bytes, alignment: 4 bytes
|
||||
print-type-size variant `Some`: 4 bytes
|
||||
print-type-size field `.0`: 4 bytes
|
||||
print-type-size variant `None`: 0 bytes
|
||||
print-type-size type: `Enum4<(), (), (), MyOption<u8>>`: 2 bytes, alignment: 1 bytes
|
||||
print-type-size variant `Four`: 2 bytes
|
||||
print-type-size field `.0`: 2 bytes
|
||||
@@ -140,4 +112,3 @@ print-type-size discriminant: 1 bytes
|
||||
print-type-size variant `Less`: 0 bytes
|
||||
print-type-size variant `Equal`: 0 bytes
|
||||
print-type-size variant `Greater`: 0 bytes
|
||||
print-type-size type: `std::marker::PhantomData<&()>`: 0 bytes, alignment: 1 bytes
|
||||
|
||||
Reference in New Issue
Block a user