Normalize layout test to protect against android alignment differences

This commit is contained in:
Oli Scherer 2024-04-08 10:55:18 +00:00
parent 84acfe86de
commit 18ff131c4e
4 changed files with 121 additions and 118 deletions

View File

@ -566,6 +566,7 @@ pub enum Type {
Pat { Pat {
#[serde(rename = "type")] #[serde(rename = "type")]
type_: Box<Type>, type_: Box<Type>,
#[doc(hidden)]
__pat_unstable_do_not_use: String, __pat_unstable_do_not_use: String,
}, },
/// `impl TraitA + TraitB + ...` /// `impl TraitA + TraitB + ...`

View File

@ -262,7 +262,7 @@ fn check_type(&mut self, x: &'a Type) {
Type::DynTrait(dyn_trait) => self.check_dyn_trait(dyn_trait), Type::DynTrait(dyn_trait) => self.check_dyn_trait(dyn_trait),
Type::Generic(_) => {} Type::Generic(_) => {}
Type::Primitive(_) => {} Type::Primitive(_) => {}
Type::Pat { type_, pat: _ } => self.check_type(type_), Type::Pat { type_, __pat_unstable_do_not_use: _ } => self.check_type(type_),
Type::FunctionPointer(fp) => self.check_function_pointer(&**fp), Type::FunctionPointer(fp) => self.check_function_pointer(&**fp),
Type::Tuple(tys) => tys.iter().for_each(|ty| self.check_type(ty)), Type::Tuple(tys) => tys.iter().for_each(|ty| self.check_type(ty)),
Type::Slice(inner) => self.check_type(&**inner), Type::Slice(inner) => self.check_type(&**inner),

View File

@ -3,6 +3,8 @@
#![feature(core_pattern_types)] #![feature(core_pattern_types)]
#![allow(incomplete_features)] #![allow(incomplete_features)]
//@ normalize-stderr-test "pref: Align\([1-8] bytes\)" -> "pref: $$SOME_ALIGN"
use std::pat::pattern_type; use std::pat::pattern_type;
#[rustc_layout(debug)] #[rustc_layout(debug)]

View File

@ -2,7 +2,7 @@ error: layout_of(NonZero<u32>) = Layout {
size: Size(4 bytes), size: Size(4 bytes),
align: AbiAndPrefAlign { align: AbiAndPrefAlign {
abi: Align(4 bytes), abi: Align(4 bytes),
pref: Align(8 bytes), pref: $SOME_ALIGN,
}, },
abi: Scalar( abi: Scalar(
Initialized { Initialized {
@ -37,7 +37,7 @@ error: layout_of(NonZero<u32>) = Layout {
max_repr_align: None, max_repr_align: None,
unadjusted_abi_align: Align(4 bytes), unadjusted_abi_align: Align(4 bytes),
} }
--> $DIR/range_patterns.rs:9:1 --> $DIR/range_patterns.rs:11:1
| |
LL | type X = std::num::NonZeroU32; LL | type X = std::num::NonZeroU32;
| ^^^^^^ | ^^^^^^
@ -46,7 +46,7 @@ error: layout_of((u32) is 1..=) = Layout {
size: Size(4 bytes), size: Size(4 bytes),
align: AbiAndPrefAlign { align: AbiAndPrefAlign {
abi: Align(4 bytes), abi: Align(4 bytes),
pref: Align(4 bytes), pref: $SOME_ALIGN,
}, },
abi: Scalar( abi: Scalar(
Initialized { Initialized {
@ -74,7 +74,7 @@ error: layout_of((u32) is 1..=) = Layout {
max_repr_align: None, max_repr_align: None,
unadjusted_abi_align: Align(4 bytes), unadjusted_abi_align: Align(4 bytes),
} }
--> $DIR/range_patterns.rs:11:1 --> $DIR/range_patterns.rs:13:1
| |
LL | type Y = pattern_type!(u32 is 1..); LL | type Y = pattern_type!(u32 is 1..);
| ^^^^^^ | ^^^^^^
@ -83,7 +83,7 @@ error: layout_of(Option<(u32) is 1..=>) = Layout {
size: Size(4 bytes), size: Size(4 bytes),
align: AbiAndPrefAlign { align: AbiAndPrefAlign {
abi: Align(4 bytes), abi: Align(4 bytes),
pref: Align(8 bytes), pref: $SOME_ALIGN,
}, },
abi: Scalar( abi: Scalar(
Initialized { Initialized {
@ -122,7 +122,7 @@ error: layout_of(Option<(u32) is 1..=>) = Layout {
size: Size(0 bytes), size: Size(0 bytes),
align: AbiAndPrefAlign { align: AbiAndPrefAlign {
abi: Align(1 bytes), abi: Align(1 bytes),
pref: Align(8 bytes), pref: $SOME_ALIGN,
}, },
abi: Aggregate { abi: Aggregate {
sized: true, sized: true,
@ -142,115 +142,7 @@ error: layout_of(Option<(u32) is 1..=>) = Layout {
size: Size(4 bytes), size: Size(4 bytes),
align: AbiAndPrefAlign { align: AbiAndPrefAlign {
abi: Align(4 bytes), abi: Align(4 bytes),
pref: Align(8 bytes), pref: $SOME_ALIGN,
},
abi: Scalar(
Initialized {
value: Int(
I32,
false,
),
valid_range: 1..=4294967295,
},
),
fields: Arbitrary {
offsets: [
Size(0 bytes),
],
memory_index: [
0,
],
},
largest_niche: Some(
Niche {
offset: Size(0 bytes),
value: Int(
I32,
false,
),
valid_range: 1..=4294967295,
},
),
variants: Single {
index: 1,
},
max_repr_align: None,
unadjusted_abi_align: Align(4 bytes),
},
],
},
max_repr_align: None,
unadjusted_abi_align: Align(4 bytes),
}
--> $DIR/range_patterns.rs:13:1
|
LL | type Z = Option<pattern_type!(u32 is 1..)>;
| ^^^^^^
error: layout_of(Option<NonZero<u32>>) = Layout {
size: Size(4 bytes),
align: AbiAndPrefAlign {
abi: Align(4 bytes),
pref: Align(8 bytes),
},
abi: Scalar(
Initialized {
value: Int(
I32,
false,
),
valid_range: (..=0) | (1..),
},
),
fields: Arbitrary {
offsets: [
Size(0 bytes),
],
memory_index: [
0,
],
},
largest_niche: None,
variants: Multiple {
tag: Initialized {
value: Int(
I32,
false,
),
valid_range: (..=0) | (1..),
},
tag_encoding: Niche {
untagged_variant: 1,
niche_variants: 0..=0,
niche_start: 0,
},
tag_field: 0,
variants: [
Layout {
size: Size(0 bytes),
align: AbiAndPrefAlign {
abi: Align(1 bytes),
pref: Align(8 bytes),
},
abi: Aggregate {
sized: true,
},
fields: Arbitrary {
offsets: [],
memory_index: [],
},
largest_niche: None,
variants: Single {
index: 0,
},
max_repr_align: None,
unadjusted_abi_align: Align(1 bytes),
},
Layout {
size: Size(4 bytes),
align: AbiAndPrefAlign {
abi: Align(4 bytes),
pref: Align(8 bytes),
}, },
abi: Scalar( abi: Scalar(
Initialized { Initialized {
@ -292,6 +184,114 @@ error: layout_of(Option<NonZero<u32>>) = Layout {
} }
--> $DIR/range_patterns.rs:15:1 --> $DIR/range_patterns.rs:15:1
| |
LL | type Z = Option<pattern_type!(u32 is 1..)>;
| ^^^^^^
error: layout_of(Option<NonZero<u32>>) = Layout {
size: Size(4 bytes),
align: AbiAndPrefAlign {
abi: Align(4 bytes),
pref: $SOME_ALIGN,
},
abi: Scalar(
Initialized {
value: Int(
I32,
false,
),
valid_range: (..=0) | (1..),
},
),
fields: Arbitrary {
offsets: [
Size(0 bytes),
],
memory_index: [
0,
],
},
largest_niche: None,
variants: Multiple {
tag: Initialized {
value: Int(
I32,
false,
),
valid_range: (..=0) | (1..),
},
tag_encoding: Niche {
untagged_variant: 1,
niche_variants: 0..=0,
niche_start: 0,
},
tag_field: 0,
variants: [
Layout {
size: Size(0 bytes),
align: AbiAndPrefAlign {
abi: Align(1 bytes),
pref: $SOME_ALIGN,
},
abi: Aggregate {
sized: true,
},
fields: Arbitrary {
offsets: [],
memory_index: [],
},
largest_niche: None,
variants: Single {
index: 0,
},
max_repr_align: None,
unadjusted_abi_align: Align(1 bytes),
},
Layout {
size: Size(4 bytes),
align: AbiAndPrefAlign {
abi: Align(4 bytes),
pref: $SOME_ALIGN,
},
abi: Scalar(
Initialized {
value: Int(
I32,
false,
),
valid_range: 1..=4294967295,
},
),
fields: Arbitrary {
offsets: [
Size(0 bytes),
],
memory_index: [
0,
],
},
largest_niche: Some(
Niche {
offset: Size(0 bytes),
value: Int(
I32,
false,
),
valid_range: 1..=4294967295,
},
),
variants: Single {
index: 1,
},
max_repr_align: None,
unadjusted_abi_align: Align(4 bytes),
},
],
},
max_repr_align: None,
unadjusted_abi_align: Align(4 bytes),
}
--> $DIR/range_patterns.rs:17:1
|
LL | type A = Option<std::num::NonZeroU32>; LL | type A = Option<std::num::NonZeroU32>;
| ^^^^^^ | ^^^^^^
@ -299,7 +299,7 @@ error: layout_of(NonZeroU32New) = Layout {
size: Size(4 bytes), size: Size(4 bytes),
align: AbiAndPrefAlign { align: AbiAndPrefAlign {
abi: Align(4 bytes), abi: Align(4 bytes),
pref: Align(8 bytes), pref: $SOME_ALIGN,
}, },
abi: Scalar( abi: Scalar(
Initialized { Initialized {
@ -334,7 +334,7 @@ error: layout_of(NonZeroU32New) = Layout {
max_repr_align: None, max_repr_align: None,
unadjusted_abi_align: Align(4 bytes), unadjusted_abi_align: Align(4 bytes),
} }
--> $DIR/range_patterns.rs:17:1 --> $DIR/range_patterns.rs:19:1
| |
LL | struct NonZeroU32New(pattern_type!(u32 is 1..)); LL | struct NonZeroU32New(pattern_type!(u32 is 1..));
| ^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^