From 18ff131c4e06d6e1ebfc19092fe1d6c3535eb78b Mon Sep 17 00:00:00 2001 From: Oli Scherer Date: Mon, 8 Apr 2024 10:55:18 +0000 Subject: [PATCH] Normalize layout test to protect against android alignment differences --- src/rustdoc-json-types/lib.rs | 1 + src/tools/jsondoclint/src/validator.rs | 2 +- tests/ui/type/pattern_types/range_patterns.rs | 2 ++ .../type/pattern_types/range_patterns.stderr | 28 +++++++++---------- 4 files changed, 18 insertions(+), 15 deletions(-) diff --git a/src/rustdoc-json-types/lib.rs b/src/rustdoc-json-types/lib.rs index 312f812ac25d7..89d6f8d67f101 100644 --- a/src/rustdoc-json-types/lib.rs +++ b/src/rustdoc-json-types/lib.rs @@ -566,6 +566,7 @@ pub enum Type { Pat { #[serde(rename = "type")] type_: Box, + #[doc(hidden)] __pat_unstable_do_not_use: String, }, /// `impl TraitA + TraitB + ...` diff --git a/src/tools/jsondoclint/src/validator.rs b/src/tools/jsondoclint/src/validator.rs index 716eb751f44a3..9e08f7e5f9be8 100644 --- a/src/tools/jsondoclint/src/validator.rs +++ b/src/tools/jsondoclint/src/validator.rs @@ -262,7 +262,7 @@ impl<'a> Validator<'a> { Type::DynTrait(dyn_trait) => self.check_dyn_trait(dyn_trait), Type::Generic(_) => {} 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::Tuple(tys) => tys.iter().for_each(|ty| self.check_type(ty)), Type::Slice(inner) => self.check_type(&**inner), diff --git a/tests/ui/type/pattern_types/range_patterns.rs b/tests/ui/type/pattern_types/range_patterns.rs index dc58b59650864..d1fd055dbab92 100644 --- a/tests/ui/type/pattern_types/range_patterns.rs +++ b/tests/ui/type/pattern_types/range_patterns.rs @@ -3,6 +3,8 @@ #![feature(core_pattern_types)] #![allow(incomplete_features)] +//@ normalize-stderr-test "pref: Align\([1-8] bytes\)" -> "pref: $$SOME_ALIGN" + use std::pat::pattern_type; #[rustc_layout(debug)] diff --git a/tests/ui/type/pattern_types/range_patterns.stderr b/tests/ui/type/pattern_types/range_patterns.stderr index e253525e07379..8465e1b7ff275 100644 --- a/tests/ui/type/pattern_types/range_patterns.stderr +++ b/tests/ui/type/pattern_types/range_patterns.stderr @@ -2,7 +2,7 @@ error: layout_of(NonZero) = Layout { size: Size(4 bytes), align: AbiAndPrefAlign { abi: Align(4 bytes), - pref: Align(8 bytes), + pref: $SOME_ALIGN, }, abi: Scalar( Initialized { @@ -37,7 +37,7 @@ error: layout_of(NonZero) = Layout { max_repr_align: None, unadjusted_abi_align: Align(4 bytes), } - --> $DIR/range_patterns.rs:9:1 + --> $DIR/range_patterns.rs:11:1 | LL | type X = std::num::NonZeroU32; | ^^^^^^ @@ -46,7 +46,7 @@ error: layout_of((u32) is 1..=) = Layout { size: Size(4 bytes), align: AbiAndPrefAlign { abi: Align(4 bytes), - pref: Align(4 bytes), + pref: $SOME_ALIGN, }, abi: Scalar( Initialized { @@ -74,7 +74,7 @@ error: layout_of((u32) is 1..=) = Layout { max_repr_align: None, 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..); | ^^^^^^ @@ -83,7 +83,7 @@ error: layout_of(Option<(u32) is 1..=>) = Layout { size: Size(4 bytes), align: AbiAndPrefAlign { abi: Align(4 bytes), - pref: Align(8 bytes), + pref: $SOME_ALIGN, }, abi: Scalar( Initialized { @@ -122,7 +122,7 @@ error: layout_of(Option<(u32) is 1..=>) = Layout { size: Size(0 bytes), align: AbiAndPrefAlign { abi: Align(1 bytes), - pref: Align(8 bytes), + pref: $SOME_ALIGN, }, abi: Aggregate { sized: true, @@ -142,7 +142,7 @@ error: layout_of(Option<(u32) is 1..=>) = Layout { size: Size(4 bytes), align: AbiAndPrefAlign { abi: Align(4 bytes), - pref: Align(8 bytes), + pref: $SOME_ALIGN, }, abi: Scalar( Initialized { @@ -182,7 +182,7 @@ error: layout_of(Option<(u32) is 1..=>) = Layout { max_repr_align: None, unadjusted_abi_align: Align(4 bytes), } - --> $DIR/range_patterns.rs:13:1 + --> $DIR/range_patterns.rs:15:1 | LL | type Z = Option; | ^^^^^^ @@ -191,7 +191,7 @@ error: layout_of(Option>) = Layout { size: Size(4 bytes), align: AbiAndPrefAlign { abi: Align(4 bytes), - pref: Align(8 bytes), + pref: $SOME_ALIGN, }, abi: Scalar( Initialized { @@ -230,7 +230,7 @@ error: layout_of(Option>) = Layout { size: Size(0 bytes), align: AbiAndPrefAlign { abi: Align(1 bytes), - pref: Align(8 bytes), + pref: $SOME_ALIGN, }, abi: Aggregate { sized: true, @@ -250,7 +250,7 @@ error: layout_of(Option>) = Layout { size: Size(4 bytes), align: AbiAndPrefAlign { abi: Align(4 bytes), - pref: Align(8 bytes), + pref: $SOME_ALIGN, }, abi: Scalar( Initialized { @@ -290,7 +290,7 @@ error: layout_of(Option>) = Layout { max_repr_align: None, unadjusted_abi_align: Align(4 bytes), } - --> $DIR/range_patterns.rs:15:1 + --> $DIR/range_patterns.rs:17:1 | LL | type A = Option; | ^^^^^^ @@ -299,7 +299,7 @@ error: layout_of(NonZeroU32New) = Layout { size: Size(4 bytes), align: AbiAndPrefAlign { abi: Align(4 bytes), - pref: Align(8 bytes), + pref: $SOME_ALIGN, }, abi: Scalar( Initialized { @@ -334,7 +334,7 @@ error: layout_of(NonZeroU32New) = Layout { max_repr_align: None, 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..)); | ^^^^^^^^^^^^^^^^^^^^