Skip to content

Commit 18ff131

Browse files
committed
Normalize layout test to protect against android alignment differences
1 parent 84acfe8 commit 18ff131

File tree

4 files changed

+18
-15
lines changed

4 files changed

+18
-15
lines changed

src/rustdoc-json-types/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -566,6 +566,7 @@ pub enum Type {
566566
Pat {
567567
#[serde(rename = "type")]
568568
type_: Box<Type>,
569+
#[doc(hidden)]
569570
__pat_unstable_do_not_use: String,
570571
},
571572
/// `impl TraitA + TraitB + ...`

src/tools/jsondoclint/src/validator.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ impl<'a> Validator<'a> {
262262
Type::DynTrait(dyn_trait) => self.check_dyn_trait(dyn_trait),
263263
Type::Generic(_) => {}
264264
Type::Primitive(_) => {}
265-
Type::Pat { type_, pat: _ } => self.check_type(type_),
265+
Type::Pat { type_, __pat_unstable_do_not_use: _ } => self.check_type(type_),
266266
Type::FunctionPointer(fp) => self.check_function_pointer(&**fp),
267267
Type::Tuple(tys) => tys.iter().for_each(|ty| self.check_type(ty)),
268268
Type::Slice(inner) => self.check_type(&**inner),

tests/ui/type/pattern_types/range_patterns.rs

+2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
#![feature(core_pattern_types)]
44
#![allow(incomplete_features)]
55

6+
//@ normalize-stderr-test "pref: Align\([1-8] bytes\)" -> "pref: $$SOME_ALIGN"
7+
68
use std::pat::pattern_type;
79

810
#[rustc_layout(debug)]

tests/ui/type/pattern_types/range_patterns.stderr

+14-14
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error: layout_of(NonZero<u32>) = Layout {
22
size: Size(4 bytes),
33
align: AbiAndPrefAlign {
44
abi: Align(4 bytes),
5-
pref: Align(8 bytes),
5+
pref: $SOME_ALIGN,
66
},
77
abi: Scalar(
88
Initialized {
@@ -37,7 +37,7 @@ error: layout_of(NonZero<u32>) = Layout {
3737
max_repr_align: None,
3838
unadjusted_abi_align: Align(4 bytes),
3939
}
40-
--> $DIR/range_patterns.rs:9:1
40+
--> $DIR/range_patterns.rs:11:1
4141
|
4242
LL | type X = std::num::NonZeroU32;
4343
| ^^^^^^
@@ -46,7 +46,7 @@ error: layout_of((u32) is 1..=) = Layout {
4646
size: Size(4 bytes),
4747
align: AbiAndPrefAlign {
4848
abi: Align(4 bytes),
49-
pref: Align(4 bytes),
49+
pref: $SOME_ALIGN,
5050
},
5151
abi: Scalar(
5252
Initialized {
@@ -74,7 +74,7 @@ error: layout_of((u32) is 1..=) = Layout {
7474
max_repr_align: None,
7575
unadjusted_abi_align: Align(4 bytes),
7676
}
77-
--> $DIR/range_patterns.rs:11:1
77+
--> $DIR/range_patterns.rs:13:1
7878
|
7979
LL | type Y = pattern_type!(u32 is 1..);
8080
| ^^^^^^
@@ -83,7 +83,7 @@ error: layout_of(Option<(u32) is 1..=>) = Layout {
8383
size: Size(4 bytes),
8484
align: AbiAndPrefAlign {
8585
abi: Align(4 bytes),
86-
pref: Align(8 bytes),
86+
pref: $SOME_ALIGN,
8787
},
8888
abi: Scalar(
8989
Initialized {
@@ -122,7 +122,7 @@ error: layout_of(Option<(u32) is 1..=>) = Layout {
122122
size: Size(0 bytes),
123123
align: AbiAndPrefAlign {
124124
abi: Align(1 bytes),
125-
pref: Align(8 bytes),
125+
pref: $SOME_ALIGN,
126126
},
127127
abi: Aggregate {
128128
sized: true,
@@ -142,7 +142,7 @@ error: layout_of(Option<(u32) is 1..=>) = Layout {
142142
size: Size(4 bytes),
143143
align: AbiAndPrefAlign {
144144
abi: Align(4 bytes),
145-
pref: Align(8 bytes),
145+
pref: $SOME_ALIGN,
146146
},
147147
abi: Scalar(
148148
Initialized {
@@ -182,7 +182,7 @@ error: layout_of(Option<(u32) is 1..=>) = Layout {
182182
max_repr_align: None,
183183
unadjusted_abi_align: Align(4 bytes),
184184
}
185-
--> $DIR/range_patterns.rs:13:1
185+
--> $DIR/range_patterns.rs:15:1
186186
|
187187
LL | type Z = Option<pattern_type!(u32 is 1..)>;
188188
| ^^^^^^
@@ -191,7 +191,7 @@ error: layout_of(Option<NonZero<u32>>) = Layout {
191191
size: Size(4 bytes),
192192
align: AbiAndPrefAlign {
193193
abi: Align(4 bytes),
194-
pref: Align(8 bytes),
194+
pref: $SOME_ALIGN,
195195
},
196196
abi: Scalar(
197197
Initialized {
@@ -230,7 +230,7 @@ error: layout_of(Option<NonZero<u32>>) = Layout {
230230
size: Size(0 bytes),
231231
align: AbiAndPrefAlign {
232232
abi: Align(1 bytes),
233-
pref: Align(8 bytes),
233+
pref: $SOME_ALIGN,
234234
},
235235
abi: Aggregate {
236236
sized: true,
@@ -250,7 +250,7 @@ error: layout_of(Option<NonZero<u32>>) = Layout {
250250
size: Size(4 bytes),
251251
align: AbiAndPrefAlign {
252252
abi: Align(4 bytes),
253-
pref: Align(8 bytes),
253+
pref: $SOME_ALIGN,
254254
},
255255
abi: Scalar(
256256
Initialized {
@@ -290,7 +290,7 @@ error: layout_of(Option<NonZero<u32>>) = Layout {
290290
max_repr_align: None,
291291
unadjusted_abi_align: Align(4 bytes),
292292
}
293-
--> $DIR/range_patterns.rs:15:1
293+
--> $DIR/range_patterns.rs:17:1
294294
|
295295
LL | type A = Option<std::num::NonZeroU32>;
296296
| ^^^^^^
@@ -299,7 +299,7 @@ error: layout_of(NonZeroU32New) = Layout {
299299
size: Size(4 bytes),
300300
align: AbiAndPrefAlign {
301301
abi: Align(4 bytes),
302-
pref: Align(8 bytes),
302+
pref: $SOME_ALIGN,
303303
},
304304
abi: Scalar(
305305
Initialized {
@@ -334,7 +334,7 @@ error: layout_of(NonZeroU32New) = Layout {
334334
max_repr_align: None,
335335
unadjusted_abi_align: Align(4 bytes),
336336
}
337-
--> $DIR/range_patterns.rs:17:1
337+
--> $DIR/range_patterns.rs:19:1
338338
|
339339
LL | struct NonZeroU32New(pattern_type!(u32 is 1..));
340340
| ^^^^^^^^^^^^^^^^^^^^

0 commit comments

Comments
 (0)