Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 96cd89f

Browse files
authoredJan 10, 2025··
Unrolled build for rust-lang#133088
Rollup merge of rust-lang#133088 - the8472:randomize-me-harder, r=workingjubilee `-Zrandomize-layout` harder. `Foo<T> != Foo<U>` Tracking issue: rust-lang#106764 Previously randomize-layout only used a deterministic shuffle based on the seed stored in an Adt's ReprOptions, meaning that `Foo<T>` and `Foo<U>` were shuffled by the same seed. This change adds a similar seed to each calculated LayoutData so that a struct can be randomized both based on the layout of its fields and its per-type seed. Primitives start with simple seed derived from some of their properties. Though some types can no longer be distinguished at that point, e.g. usize and u64 will still be treated the same.
2 parents 88ab2d8 + d89b6d5 commit 96cd89f

39 files changed

+400
-78
lines changed
 

‎compiler/rustc_abi/src/layout.rs‎

Lines changed: 36 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,8 @@ impl<Cx: HasDataLayout> LayoutCalculator<Cx> {
119119
.chain(Niche::from_scalar(dl, Size::ZERO, a))
120120
.max_by_key(|niche| niche.available(dl));
121121

122+
let combined_seed = a.size(&self.cx).bytes().wrapping_add(b.size(&self.cx).bytes());
123+
122124
LayoutData {
123125
variants: Variants::Single { index: VariantIdx::new(0) },
124126
fields: FieldsShape::Arbitrary {
@@ -131,6 +133,7 @@ impl<Cx: HasDataLayout> LayoutCalculator<Cx> {
131133
size,
132134
max_repr_align: None,
133135
unadjusted_abi_align: align.abi,
136+
randomization_seed: combined_seed,
134137
}
135138
}
136139

@@ -223,6 +226,7 @@ impl<Cx: HasDataLayout> LayoutCalculator<Cx> {
223226
size: Size::ZERO,
224227
max_repr_align: None,
225228
unadjusted_abi_align: dl.i8_align.abi,
229+
randomization_seed: 0,
226230
}
227231
}
228232

@@ -385,6 +389,11 @@ impl<Cx: HasDataLayout> LayoutCalculator<Cx> {
385389
return Err(LayoutCalculatorError::EmptyUnion);
386390
};
387391

392+
let combined_seed = only_variant
393+
.iter()
394+
.map(|v| v.randomization_seed)
395+
.fold(repr.field_shuffle_seed, |acc, seed| acc.wrapping_add(seed));
396+
388397
Ok(LayoutData {
389398
variants: Variants::Single { index: only_variant_idx },
390399
fields: FieldsShape::Union(union_field_count),
@@ -394,6 +403,7 @@ impl<Cx: HasDataLayout> LayoutCalculator<Cx> {
394403
size: size.align_to(align.abi),
395404
max_repr_align,
396405
unadjusted_abi_align,
406+
randomization_seed: combined_seed,
397407
})
398408
}
399409

@@ -650,6 +660,11 @@ impl<Cx: HasDataLayout> LayoutCalculator<Cx> {
650660
BackendRepr::Memory { sized: true }
651661
};
652662

663+
let combined_seed = variant_layouts
664+
.iter()
665+
.map(|v| v.randomization_seed)
666+
.fold(repr.field_shuffle_seed, |acc, seed| acc.wrapping_add(seed));
667+
653668
let layout = LayoutData {
654669
variants: Variants::Multiple {
655670
tag: niche_scalar,
@@ -671,6 +686,7 @@ impl<Cx: HasDataLayout> LayoutCalculator<Cx> {
671686
align,
672687
max_repr_align,
673688
unadjusted_abi_align,
689+
randomization_seed: combined_seed,
674690
};
675691

676692
Some(TmpLayout { layout, variants: variant_layouts })
@@ -961,6 +977,11 @@ impl<Cx: HasDataLayout> LayoutCalculator<Cx> {
961977

962978
let largest_niche = Niche::from_scalar(dl, Size::ZERO, tag);
963979

980+
let combined_seed = layout_variants
981+
.iter()
982+
.map(|v| v.randomization_seed)
983+
.fold(repr.field_shuffle_seed, |acc, seed| acc.wrapping_add(seed));
984+
964985
let tagged_layout = LayoutData {
965986
variants: Variants::Multiple {
966987
tag,
@@ -978,6 +999,7 @@ impl<Cx: HasDataLayout> LayoutCalculator<Cx> {
978999
size,
9791000
max_repr_align,
9801001
unadjusted_abi_align,
1002+
randomization_seed: combined_seed,
9811003
};
9821004

9831005
let tagged_layout = TmpLayout { layout: tagged_layout, variants: layout_variants };
@@ -1030,12 +1052,15 @@ impl<Cx: HasDataLayout> LayoutCalculator<Cx> {
10301052
let mut max_repr_align = repr.align;
10311053
let mut inverse_memory_index: IndexVec<u32, FieldIdx> = fields.indices().collect();
10321054
let optimize_field_order = !repr.inhibit_struct_field_reordering();
1033-
if optimize_field_order && fields.len() > 1 {
1034-
let end =
1035-
if let StructKind::MaybeUnsized = kind { fields.len() - 1 } else { fields.len() };
1036-
let optimizing = &mut inverse_memory_index.raw[..end];
1037-
let fields_excluding_tail = &fields.raw[..end];
1055+
let end = if let StructKind::MaybeUnsized = kind { fields.len() - 1 } else { fields.len() };
1056+
let optimizing = &mut inverse_memory_index.raw[..end];
1057+
let fields_excluding_tail = &fields.raw[..end];
1058+
// unsizable tail fields are excluded so that we use the same seed for the sized and unsized layouts.
1059+
let field_seed = fields_excluding_tail
1060+
.iter()
1061+
.fold(0u64, |acc, f| acc.wrapping_add(f.randomization_seed));
10381062

1063+
if optimize_field_order && fields.len() > 1 {
10391064
// If `-Z randomize-layout` was enabled for the type definition we can shuffle
10401065
// the field ordering to try and catch some code making assumptions about layouts
10411066
// we don't guarantee.
@@ -1046,8 +1071,9 @@ impl<Cx: HasDataLayout> LayoutCalculator<Cx> {
10461071
use rand::seq::SliceRandom;
10471072
// `ReprOptions.field_shuffle_seed` is a deterministic seed we can use to randomize field
10481073
// ordering.
1049-
let mut rng =
1050-
rand_xoshiro::Xoshiro128StarStar::seed_from_u64(repr.field_shuffle_seed);
1074+
let mut rng = rand_xoshiro::Xoshiro128StarStar::seed_from_u64(
1075+
field_seed.wrapping_add(repr.field_shuffle_seed),
1076+
);
10511077

10521078
// Shuffle the ordering of the fields.
10531079
optimizing.shuffle(&mut rng);
@@ -1344,6 +1370,8 @@ impl<Cx: HasDataLayout> LayoutCalculator<Cx> {
13441370
unadjusted_abi_align
13451371
};
13461372

1373+
let seed = field_seed.wrapping_add(repr.field_shuffle_seed);
1374+
13471375
Ok(LayoutData {
13481376
variants: Variants::Single { index: VariantIdx::new(0) },
13491377
fields: FieldsShape::Arbitrary { offsets, memory_index },
@@ -1353,6 +1381,7 @@ impl<Cx: HasDataLayout> LayoutCalculator<Cx> {
13531381
size,
13541382
max_repr_align,
13551383
unadjusted_abi_align,
1384+
randomization_seed: seed,
13561385
})
13571386
}
13581387

‎compiler/rustc_abi/src/lib.rs‎

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1719,6 +1719,18 @@ pub struct LayoutData<FieldIdx: Idx, VariantIdx: Idx> {
17191719
/// Only used on aarch64-linux, where the argument passing ABI ignores the requested alignment
17201720
/// in some cases.
17211721
pub unadjusted_abi_align: Align,
1722+
1723+
/// The randomization seed based on this type's own repr and its fields.
1724+
///
1725+
/// Since randomization is toggled on a per-crate basis even crates that do not have randomization
1726+
/// enabled should still calculate a seed so that downstream uses can use it to distinguish different
1727+
/// types.
1728+
///
1729+
/// For every T and U for which we do not guarantee that a repr(Rust) `Foo<T>` can be coerced or
1730+
/// transmuted to `Foo<U>` we aim to create probalistically distinct seeds so that Foo can choose
1731+
/// to reorder its fields based on that information. The current implementation is a conservative
1732+
/// approximation of this goal.
1733+
pub randomization_seed: u64,
17221734
}
17231735

17241736
impl<FieldIdx: Idx, VariantIdx: Idx> LayoutData<FieldIdx, VariantIdx> {
@@ -1739,6 +1751,30 @@ impl<FieldIdx: Idx, VariantIdx: Idx> LayoutData<FieldIdx, VariantIdx> {
17391751
let largest_niche = Niche::from_scalar(cx, Size::ZERO, scalar);
17401752
let size = scalar.size(cx);
17411753
let align = scalar.align(cx);
1754+
1755+
let range = scalar.valid_range(cx);
1756+
1757+
// All primitive types for which we don't have subtype coercions should get a distinct seed,
1758+
// so that types wrapping them can use randomization to arrive at distinct layouts.
1759+
//
1760+
// Some type information is already lost at this point, so as an approximation we derive
1761+
// the seed from what remains. For example on 64-bit targets usize and u64 can no longer
1762+
// be distinguished.
1763+
let randomization_seed = size
1764+
.bytes()
1765+
.wrapping_add(
1766+
match scalar.primitive() {
1767+
Primitive::Int(_, true) => 1,
1768+
Primitive::Int(_, false) => 2,
1769+
Primitive::Float(_) => 3,
1770+
Primitive::Pointer(_) => 4,
1771+
} << 32,
1772+
)
1773+
// distinguishes references from pointers
1774+
.wrapping_add((range.start as u64).rotate_right(16))
1775+
// distinguishes char from u32 and bool from u8
1776+
.wrapping_add((range.end as u64).rotate_right(16));
1777+
17421778
LayoutData {
17431779
variants: Variants::Single { index: VariantIdx::new(0) },
17441780
fields: FieldsShape::Primitive,
@@ -1748,6 +1784,7 @@ impl<FieldIdx: Idx, VariantIdx: Idx> LayoutData<FieldIdx, VariantIdx> {
17481784
align,
17491785
max_repr_align: None,
17501786
unadjusted_abi_align: align.abi,
1787+
randomization_seed,
17511788
}
17521789
}
17531790
}
@@ -1770,6 +1807,7 @@ where
17701807
variants,
17711808
max_repr_align,
17721809
unadjusted_abi_align,
1810+
ref randomization_seed,
17731811
} = self;
17741812
f.debug_struct("Layout")
17751813
.field("size", size)
@@ -1780,6 +1818,7 @@ where
17801818
.field("variants", variants)
17811819
.field("max_repr_align", max_repr_align)
17821820
.field("unadjusted_abi_align", unadjusted_abi_align)
1821+
.field("randomization_seed", randomization_seed)
17831822
.finish()
17841823
}
17851824
}

‎compiler/rustc_middle/src/ty/layout.rs‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -770,6 +770,7 @@ where
770770
size: Size::ZERO,
771771
max_repr_align: None,
772772
unadjusted_abi_align: tcx.data_layout.i8_align.abi,
773+
randomization_seed: 0,
773774
})
774775
}
775776

‎compiler/rustc_ty_utils/src/layout.rs‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,7 @@ fn layout_of_uncached<'tcx>(
347347
size,
348348
max_repr_align: None,
349349
unadjusted_abi_align: element.align.abi,
350+
randomization_seed: element.randomization_seed.wrapping_add(count),
350351
})
351352
}
352353
ty::Slice(element) => {
@@ -360,6 +361,8 @@ fn layout_of_uncached<'tcx>(
360361
size: Size::ZERO,
361362
max_repr_align: None,
362363
unadjusted_abi_align: element.align.abi,
364+
// adding a randomly chosen value to distinguish slices
365+
randomization_seed: element.randomization_seed.wrapping_add(0x2dcba99c39784102),
363366
})
364367
}
365368
ty::Str => tcx.mk_layout(LayoutData {
@@ -371,6 +374,8 @@ fn layout_of_uncached<'tcx>(
371374
size: Size::ZERO,
372375
max_repr_align: None,
373376
unadjusted_abi_align: dl.i8_align.abi,
377+
// another random value
378+
randomization_seed: 0xc1325f37d127be22,
374379
}),
375380

376381
// Odd unit types.
@@ -542,6 +547,7 @@ fn layout_of_uncached<'tcx>(
542547
align,
543548
max_repr_align: None,
544549
unadjusted_abi_align: align.abi,
550+
randomization_seed: e_ly.randomization_seed.wrapping_add(e_len),
545551
})
546552
}
547553

@@ -999,6 +1005,9 @@ fn coroutine_layout<'tcx>(
9991005
BackendRepr::Memory { sized: true }
10001006
};
10011007

1008+
// this is similar to how ReprOptions populates its field_shuffle_seed
1009+
let def_hash = tcx.def_path_hash(def_id).0.to_smaller_hash().as_u64();
1010+
10021011
let layout = tcx.mk_layout(LayoutData {
10031012
variants: Variants::Multiple {
10041013
tag,
@@ -1019,6 +1028,7 @@ fn coroutine_layout<'tcx>(
10191028
align,
10201029
max_repr_align: None,
10211030
unadjusted_abi_align: align.abi,
1031+
randomization_seed: def_hash,
10221032
});
10231033
debug!("coroutine layout ({:?}): {:#?}", ty, layout);
10241034
Ok(layout)

‎src/tools/rust-analyzer/crates/hir-ty/src/layout.rs‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,7 @@ fn layout_of_simd_ty(
197197
align,
198198
max_repr_align: None,
199199
unadjusted_abi_align: align.abi,
200+
randomization_seed: 0,
200201
}))
201202
}
202203

@@ -313,6 +314,7 @@ pub fn layout_of_ty_query(
313314
size,
314315
max_repr_align: None,
315316
unadjusted_abi_align: element.align.abi,
317+
randomization_seed: 0,
316318
}
317319
}
318320
TyKind::Slice(element) => {
@@ -326,6 +328,7 @@ pub fn layout_of_ty_query(
326328
size: Size::ZERO,
327329
max_repr_align: None,
328330
unadjusted_abi_align: element.align.abi,
331+
randomization_seed: 0,
329332
}
330333
}
331334
TyKind::Str => Layout {
@@ -337,6 +340,7 @@ pub fn layout_of_ty_query(
337340
size: Size::ZERO,
338341
max_repr_align: None,
339342
unadjusted_abi_align: dl.i8_align.abi,
343+
randomization_seed: 0,
340344
},
341345
// Potentially-wide pointers.
342346
TyKind::Ref(_, _, pointee) | TyKind::Raw(_, pointee) => {

‎tests/ui/abi/c-zst.aarch64-darwin.stderr‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ error: fn_abi_of(pass_zst) = FnAbi {
2222
},
2323
max_repr_align: None,
2424
unadjusted_abi_align: $SOME_ALIGN,
25+
randomization_seed: 0,
2526
},
2627
},
2728
mode: Ignore,
@@ -49,6 +50,7 @@ error: fn_abi_of(pass_zst) = FnAbi {
4950
},
5051
max_repr_align: None,
5152
unadjusted_abi_align: $SOME_ALIGN,
53+
randomization_seed: 0,
5254
},
5355
},
5456
mode: Ignore,

‎tests/ui/abi/c-zst.powerpc-linux.stderr‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ error: fn_abi_of(pass_zst) = FnAbi {
2222
},
2323
max_repr_align: None,
2424
unadjusted_abi_align: $SOME_ALIGN,
25+
randomization_seed: 0,
2526
},
2627
},
2728
mode: Indirect {
@@ -60,6 +61,7 @@ error: fn_abi_of(pass_zst) = FnAbi {
6061
},
6162
max_repr_align: None,
6263
unadjusted_abi_align: $SOME_ALIGN,
64+
randomization_seed: 0,
6365
},
6466
},
6567
mode: Ignore,

‎tests/ui/abi/c-zst.s390x-linux.stderr‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ error: fn_abi_of(pass_zst) = FnAbi {
2222
},
2323
max_repr_align: None,
2424
unadjusted_abi_align: $SOME_ALIGN,
25+
randomization_seed: 0,
2526
},
2627
},
2728
mode: Indirect {
@@ -60,6 +61,7 @@ error: fn_abi_of(pass_zst) = FnAbi {
6061
},
6162
max_repr_align: None,
6263
unadjusted_abi_align: $SOME_ALIGN,
64+
randomization_seed: 0,
6365
},
6466
},
6567
mode: Ignore,

‎tests/ui/abi/c-zst.sparc64-linux.stderr‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ error: fn_abi_of(pass_zst) = FnAbi {
2222
},
2323
max_repr_align: None,
2424
unadjusted_abi_align: $SOME_ALIGN,
25+
randomization_seed: 0,
2526
},
2627
},
2728
mode: Indirect {
@@ -60,6 +61,7 @@ error: fn_abi_of(pass_zst) = FnAbi {
6061
},
6162
max_repr_align: None,
6263
unadjusted_abi_align: $SOME_ALIGN,
64+
randomization_seed: 0,
6365
},
6466
},
6567
mode: Ignore,

‎tests/ui/abi/c-zst.x86_64-linux.stderr‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ error: fn_abi_of(pass_zst) = FnAbi {
2222
},
2323
max_repr_align: None,
2424
unadjusted_abi_align: $SOME_ALIGN,
25+
randomization_seed: 0,
2526
},
2627
},
2728
mode: Ignore,
@@ -49,6 +50,7 @@ error: fn_abi_of(pass_zst) = FnAbi {
4950
},
5051
max_repr_align: None,
5152
unadjusted_abi_align: $SOME_ALIGN,
53+
randomization_seed: 0,
5254
},
5355
},
5456
mode: Ignore,

‎tests/ui/abi/c-zst.x86_64-pc-windows-gnu.stderr‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ error: fn_abi_of(pass_zst) = FnAbi {
2222
},
2323
max_repr_align: None,
2424
unadjusted_abi_align: $SOME_ALIGN,
25+
randomization_seed: 0,
2526
},
2627
},
2728
mode: Indirect {
@@ -60,6 +61,7 @@ error: fn_abi_of(pass_zst) = FnAbi {
6061
},
6162
max_repr_align: None,
6263
unadjusted_abi_align: $SOME_ALIGN,
64+
randomization_seed: 0,
6365
},
6466
},
6567
mode: Ignore,

‎tests/ui/abi/debug.rs‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
//@ normalize-stderr: "(abi|pref|unadjusted_abi_align): Align\([1-8] bytes\)" -> "$1: $$SOME_ALIGN"
2+
//@ normalize-stderr: "randomization_seed: \d+" -> "randomization_seed: $$SEED"
23
//@ normalize-stderr: "(size): Size\([48] bytes\)" -> "$1: $$SOME_SIZE"
34
//@ normalize-stderr: "(can_unwind): (true|false)" -> "$1: $$SOME_BOOL"
45
//@ normalize-stderr: "(valid_range): 0\.\.=(4294967295|18446744073709551615)" -> "$1: $$FULL"

‎tests/ui/abi/debug.stderr‎

Lines changed: 35 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ error: fn_abi_of(test) = FnAbi {
2525
},
2626
max_repr_align: None,
2727
unadjusted_abi_align: $SOME_ALIGN,
28+
randomization_seed: $SEED,
2829
},
2930
},
3031
mode: Direct(
@@ -71,6 +72,7 @@ error: fn_abi_of(test) = FnAbi {
7172
},
7273
max_repr_align: None,
7374
unadjusted_abi_align: $SOME_ALIGN,
75+
randomization_seed: $SEED,
7476
},
7577
},
7678
mode: Direct(
@@ -87,7 +89,7 @@ error: fn_abi_of(test) = FnAbi {
8789
conv: Rust,
8890
can_unwind: $SOME_BOOL,
8991
}
90-
--> $DIR/debug.rs:15:1
92+
--> $DIR/debug.rs:16:1
9193
|
9294
LL | fn test(_x: u8) -> bool { true }
9395
| ^^^^^^^^^^^^^^^^^^^^^^^
@@ -128,6 +130,7 @@ error: fn_abi_of(TestFnPtr) = FnAbi {
128130
},
129131
max_repr_align: None,
130132
unadjusted_abi_align: $SOME_ALIGN,
133+
randomization_seed: $SEED,
131134
},
132135
},
133136
mode: Direct(
@@ -165,6 +168,7 @@ error: fn_abi_of(TestFnPtr) = FnAbi {
165168
},
166169
max_repr_align: None,
167170
unadjusted_abi_align: $SOME_ALIGN,
171+
randomization_seed: $SEED,
168172
},
169173
},
170174
mode: Direct(
@@ -181,7 +185,7 @@ error: fn_abi_of(TestFnPtr) = FnAbi {
181185
conv: Rust,
182186
can_unwind: $SOME_BOOL,
183187
}
184-
--> $DIR/debug.rs:18:1
188+
--> $DIR/debug.rs:19:1
185189
|
186190
LL | type TestFnPtr = fn(bool) -> u8;
187191
| ^^^^^^^^^^^^^^
@@ -214,6 +218,7 @@ error: fn_abi_of(test_generic) = FnAbi {
214218
},
215219
max_repr_align: None,
216220
unadjusted_abi_align: $SOME_ALIGN,
221+
randomization_seed: $SEED,
217222
},
218223
},
219224
mode: Direct(
@@ -248,6 +253,7 @@ error: fn_abi_of(test_generic) = FnAbi {
248253
},
249254
max_repr_align: None,
250255
unadjusted_abi_align: $SOME_ALIGN,
256+
randomization_seed: $SEED,
251257
},
252258
},
253259
mode: Ignore,
@@ -257,13 +263,13 @@ error: fn_abi_of(test_generic) = FnAbi {
257263
conv: Rust,
258264
can_unwind: $SOME_BOOL,
259265
}
260-
--> $DIR/debug.rs:21:1
266+
--> $DIR/debug.rs:22:1
261267
|
262268
LL | fn test_generic<T>(_x: *const T) { }
263269
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
264270

265271
error: `#[rustc_abi]` can only be applied to function items, type aliases, and associated functions
266-
--> $DIR/debug.rs:24:1
272+
--> $DIR/debug.rs:25:1
267273
|
268274
LL | const C: () = ();
269275
| ^^^^^^^^^^^
@@ -296,6 +302,7 @@ error: ABIs are not compatible
296302
},
297303
max_repr_align: None,
298304
unadjusted_abi_align: $SOME_ALIGN,
305+
randomization_seed: $SEED,
299306
},
300307
},
301308
mode: Direct(
@@ -330,6 +337,7 @@ error: ABIs are not compatible
330337
},
331338
max_repr_align: None,
332339
unadjusted_abi_align: $SOME_ALIGN,
340+
randomization_seed: $SEED,
333341
},
334342
},
335343
mode: Ignore,
@@ -366,6 +374,7 @@ error: ABIs are not compatible
366374
},
367375
max_repr_align: None,
368376
unadjusted_abi_align: $SOME_ALIGN,
377+
randomization_seed: $SEED,
369378
},
370379
},
371380
mode: Direct(
@@ -400,6 +409,7 @@ error: ABIs are not compatible
400409
},
401410
max_repr_align: None,
402411
unadjusted_abi_align: $SOME_ALIGN,
412+
randomization_seed: $SEED,
403413
},
404414
},
405415
mode: Ignore,
@@ -409,7 +419,7 @@ error: ABIs are not compatible
409419
conv: Rust,
410420
can_unwind: $SOME_BOOL,
411421
}
412-
--> $DIR/debug.rs:40:1
422+
--> $DIR/debug.rs:41:1
413423
|
414424
LL | type TestAbiNe = (fn(u8), fn(u32));
415425
| ^^^^^^^^^^^^^^
@@ -439,6 +449,7 @@ error: ABIs are not compatible
439449
},
440450
max_repr_align: None,
441451
unadjusted_abi_align: $SOME_ALIGN,
452+
randomization_seed: $SEED,
442453
},
443454
},
444455
mode: Indirect {
@@ -477,6 +488,7 @@ error: ABIs are not compatible
477488
},
478489
max_repr_align: None,
479490
unadjusted_abi_align: $SOME_ALIGN,
491+
randomization_seed: $SEED,
480492
},
481493
},
482494
mode: Ignore,
@@ -510,6 +522,7 @@ error: ABIs are not compatible
510522
},
511523
max_repr_align: None,
512524
unadjusted_abi_align: $SOME_ALIGN,
525+
randomization_seed: $SEED,
513526
},
514527
},
515528
mode: Indirect {
@@ -548,6 +561,7 @@ error: ABIs are not compatible
548561
},
549562
max_repr_align: None,
550563
unadjusted_abi_align: $SOME_ALIGN,
564+
randomization_seed: $SEED,
551565
},
552566
},
553567
mode: Ignore,
@@ -557,7 +571,7 @@ error: ABIs are not compatible
557571
conv: Rust,
558572
can_unwind: $SOME_BOOL,
559573
}
560-
--> $DIR/debug.rs:43:1
574+
--> $DIR/debug.rs:44:1
561575
|
562576
LL | type TestAbiNeLarger = (fn([u8; 32]), fn([u32; 32]));
563577
| ^^^^^^^^^^^^^^^^^^^^
@@ -589,6 +603,7 @@ error: ABIs are not compatible
589603
},
590604
max_repr_align: None,
591605
unadjusted_abi_align: $SOME_ALIGN,
606+
randomization_seed: $SEED,
592607
},
593608
},
594609
mode: Direct(
@@ -623,6 +638,7 @@ error: ABIs are not compatible
623638
},
624639
max_repr_align: None,
625640
unadjusted_abi_align: $SOME_ALIGN,
641+
randomization_seed: $SEED,
626642
},
627643
},
628644
mode: Ignore,
@@ -659,6 +675,7 @@ error: ABIs are not compatible
659675
},
660676
max_repr_align: None,
661677
unadjusted_abi_align: $SOME_ALIGN,
678+
randomization_seed: $SEED,
662679
},
663680
},
664681
mode: Direct(
@@ -693,6 +710,7 @@ error: ABIs are not compatible
693710
},
694711
max_repr_align: None,
695712
unadjusted_abi_align: $SOME_ALIGN,
713+
randomization_seed: $SEED,
696714
},
697715
},
698716
mode: Ignore,
@@ -702,7 +720,7 @@ error: ABIs are not compatible
702720
conv: Rust,
703721
can_unwind: $SOME_BOOL,
704722
}
705-
--> $DIR/debug.rs:46:1
723+
--> $DIR/debug.rs:47:1
706724
|
707725
LL | type TestAbiNeFloat = (fn(f32), fn(u32));
708726
| ^^^^^^^^^^^^^^^^^^^
@@ -735,6 +753,7 @@ error: ABIs are not compatible
735753
},
736754
max_repr_align: None,
737755
unadjusted_abi_align: $SOME_ALIGN,
756+
randomization_seed: $SEED,
738757
},
739758
},
740759
mode: Direct(
@@ -769,6 +788,7 @@ error: ABIs are not compatible
769788
},
770789
max_repr_align: None,
771790
unadjusted_abi_align: $SOME_ALIGN,
791+
randomization_seed: $SEED,
772792
},
773793
},
774794
mode: Ignore,
@@ -805,6 +825,7 @@ error: ABIs are not compatible
805825
},
806826
max_repr_align: None,
807827
unadjusted_abi_align: $SOME_ALIGN,
828+
randomization_seed: $SEED,
808829
},
809830
},
810831
mode: Direct(
@@ -839,6 +860,7 @@ error: ABIs are not compatible
839860
},
840861
max_repr_align: None,
841862
unadjusted_abi_align: $SOME_ALIGN,
863+
randomization_seed: $SEED,
842864
},
843865
},
844866
mode: Ignore,
@@ -848,13 +870,13 @@ error: ABIs are not compatible
848870
conv: Rust,
849871
can_unwind: $SOME_BOOL,
850872
}
851-
--> $DIR/debug.rs:50:1
873+
--> $DIR/debug.rs:51:1
852874
|
853875
LL | type TestAbiNeSign = (fn(i32), fn(u32));
854876
| ^^^^^^^^^^^^^^^^^^
855877

856878
error[E0277]: the size for values of type `str` cannot be known at compilation time
857-
--> $DIR/debug.rs:53:46
879+
--> $DIR/debug.rs:54:46
858880
|
859881
LL | type TestAbiEqNonsense = (fn((str, str)), fn((str, str)));
860882
| ^^^^^^^^^^ doesn't have a size known at compile-time
@@ -863,7 +885,7 @@ LL | type TestAbiEqNonsense = (fn((str, str)), fn((str, str)));
863885
= note: only the last element of a tuple may have a dynamically sized type
864886

865887
error: `#[rustc_abi]` can only be applied to function items, type aliases, and associated functions
866-
--> $DIR/debug.rs:28:5
888+
--> $DIR/debug.rs:29:5
867889
|
868890
LL | const C: () = ();
869891
| ^^^^^^^^^^^
@@ -906,6 +928,7 @@ error: fn_abi_of(assoc_test) = FnAbi {
906928
},
907929
max_repr_align: None,
908930
unadjusted_abi_align: $SOME_ALIGN,
931+
randomization_seed: $SEED,
909932
},
910933
},
911934
mode: Direct(
@@ -942,6 +965,7 @@ error: fn_abi_of(assoc_test) = FnAbi {
942965
},
943966
max_repr_align: None,
944967
unadjusted_abi_align: $SOME_ALIGN,
968+
randomization_seed: $SEED,
945969
},
946970
},
947971
mode: Ignore,
@@ -951,7 +975,7 @@ error: fn_abi_of(assoc_test) = FnAbi {
951975
conv: Rust,
952976
can_unwind: $SOME_BOOL,
953977
}
954-
--> $DIR/debug.rs:33:5
978+
--> $DIR/debug.rs:34:5
955979
|
956980
LL | fn assoc_test(&self) { }
957981
| ^^^^^^^^^^^^^^^^^^^^

‎tests/ui/abi/sysv64-zst.stderr‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ error: fn_abi_of(pass_zst) = FnAbi {
2222
},
2323
max_repr_align: None,
2424
unadjusted_abi_align: $SOME_ALIGN,
25+
randomization_seed: 0,
2526
},
2627
},
2728
mode: Ignore,
@@ -49,6 +50,7 @@ error: fn_abi_of(pass_zst) = FnAbi {
4950
},
5051
max_repr_align: None,
5152
unadjusted_abi_align: $SOME_ALIGN,
53+
randomization_seed: 0,
5254
},
5355
},
5456
mode: Ignore,

‎tests/ui/abi/win64-zst.x86_64-linux.stderr‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ error: fn_abi_of(pass_zst) = FnAbi {
2222
},
2323
max_repr_align: None,
2424
unadjusted_abi_align: $SOME_ALIGN,
25+
randomization_seed: 0,
2526
},
2627
},
2728
mode: Ignore,
@@ -49,6 +50,7 @@ error: fn_abi_of(pass_zst) = FnAbi {
4950
},
5051
max_repr_align: None,
5152
unadjusted_abi_align: $SOME_ALIGN,
53+
randomization_seed: 0,
5254
},
5355
},
5456
mode: Ignore,

‎tests/ui/abi/win64-zst.x86_64-windows-gnu.stderr‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ error: fn_abi_of(pass_zst) = FnAbi {
2222
},
2323
max_repr_align: None,
2424
unadjusted_abi_align: $SOME_ALIGN,
25+
randomization_seed: 0,
2526
},
2627
},
2728
mode: Indirect {
@@ -60,6 +61,7 @@ error: fn_abi_of(pass_zst) = FnAbi {
6061
},
6162
max_repr_align: None,
6263
unadjusted_abi_align: $SOME_ALIGN,
64+
randomization_seed: 0,
6365
},
6466
},
6567
mode: Ignore,

‎tests/ui/abi/win64-zst.x86_64-windows-msvc.stderr‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ error: fn_abi_of(pass_zst) = FnAbi {
2222
},
2323
max_repr_align: None,
2424
unadjusted_abi_align: $SOME_ALIGN,
25+
randomization_seed: 0,
2526
},
2627
},
2728
mode: Ignore,
@@ -49,6 +50,7 @@ error: fn_abi_of(pass_zst) = FnAbi {
4950
},
5051
max_repr_align: None,
5152
unadjusted_abi_align: $SOME_ALIGN,
53+
randomization_seed: 0,
5254
},
5355
},
5456
mode: Ignore,

‎tests/ui/layout/debug.rs‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
//@ normalize-stderr: "pref: Align\([1-8] bytes\)" -> "pref: $$SOME_ALIGN"
2+
//@ normalize-stderr: "randomization_seed: \d+" -> "randomization_seed: $$SEED"
23
#![feature(never_type, rustc_attrs, type_alias_impl_trait, repr_simd)]
34
#![crate_type = "lib"]
45

‎tests/ui/layout/debug.stderr‎

Lines changed: 37 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: unions cannot have zero fields
2-
--> $DIR/debug.rs:82:1
2+
--> $DIR/debug.rs:83:1
33
|
44
LL | union EmptyUnion {}
55
| ^^^^^^^^^^^^^^^^^^^
@@ -61,6 +61,7 @@ error: layout_of(E) = Layout {
6161
},
6262
max_repr_align: None,
6363
unadjusted_abi_align: Align(1 bytes),
64+
randomization_seed: $SEED,
6465
},
6566
Layout {
6667
size: Size(12 bytes),
@@ -87,13 +88,15 @@ error: layout_of(E) = Layout {
8788
},
8889
max_repr_align: None,
8990
unadjusted_abi_align: Align(4 bytes),
91+
randomization_seed: $SEED,
9092
},
9193
],
9294
},
9395
max_repr_align: None,
9496
unadjusted_abi_align: Align(4 bytes),
97+
randomization_seed: $SEED,
9598
}
96-
--> $DIR/debug.rs:7:1
99+
--> $DIR/debug.rs:8:1
97100
|
98101
LL | enum E { Foo, Bar(!, i32, i32) }
99102
| ^^^^^^
@@ -138,8 +141,9 @@ error: layout_of(S) = Layout {
138141
},
139142
max_repr_align: None,
140143
unadjusted_abi_align: Align(4 bytes),
144+
randomization_seed: $SEED,
141145
}
142-
--> $DIR/debug.rs:10:1
146+
--> $DIR/debug.rs:11:1
143147
|
144148
LL | struct S { f1: i32, f2: (), f3: i32 }
145149
| ^^^^^^^^
@@ -162,8 +166,9 @@ error: layout_of(U) = Layout {
162166
},
163167
max_repr_align: None,
164168
unadjusted_abi_align: Align(4 bytes),
169+
randomization_seed: $SEED,
165170
}
166-
--> $DIR/debug.rs:13:1
171+
--> $DIR/debug.rs:14:1
167172
|
168173
LL | union U { f1: (i32, i32), f3: i32 }
169174
| ^^^^^^^
@@ -255,6 +260,7 @@ error: layout_of(Result<i32, i32>) = Layout {
255260
},
256261
max_repr_align: None,
257262
unadjusted_abi_align: Align(4 bytes),
263+
randomization_seed: $SEED,
258264
},
259265
Layout {
260266
size: Size(8 bytes),
@@ -292,13 +298,15 @@ error: layout_of(Result<i32, i32>) = Layout {
292298
},
293299
max_repr_align: None,
294300
unadjusted_abi_align: Align(4 bytes),
301+
randomization_seed: $SEED,
295302
},
296303
],
297304
},
298305
max_repr_align: None,
299306
unadjusted_abi_align: Align(4 bytes),
307+
randomization_seed: $SEED,
300308
}
301-
--> $DIR/debug.rs:16:1
309+
--> $DIR/debug.rs:17:1
302310
|
303311
LL | type Test = Result<i32, i32>;
304312
| ^^^^^^^^^
@@ -325,8 +333,9 @@ error: layout_of(i32) = Layout {
325333
},
326334
max_repr_align: None,
327335
unadjusted_abi_align: Align(4 bytes),
336+
randomization_seed: $SEED,
328337
}
329-
--> $DIR/debug.rs:19:1
338+
--> $DIR/debug.rs:20:1
330339
|
331340
LL | type T = impl std::fmt::Debug;
332341
| ^^^^^^
@@ -349,8 +358,9 @@ error: layout_of(V) = Layout {
349358
},
350359
max_repr_align: None,
351360
unadjusted_abi_align: Align(2 bytes),
361+
randomization_seed: $SEED,
352362
}
353-
--> $DIR/debug.rs:25:1
363+
--> $DIR/debug.rs:26:1
354364
|
355365
LL | pub union V {
356366
| ^^^^^^^^^^^
@@ -373,8 +383,9 @@ error: layout_of(W) = Layout {
373383
},
374384
max_repr_align: None,
375385
unadjusted_abi_align: Align(2 bytes),
386+
randomization_seed: $SEED,
376387
}
377-
--> $DIR/debug.rs:31:1
388+
--> $DIR/debug.rs:32:1
378389
|
379390
LL | pub union W {
380391
| ^^^^^^^^^^^
@@ -397,8 +408,9 @@ error: layout_of(Y) = Layout {
397408
},
398409
max_repr_align: None,
399410
unadjusted_abi_align: Align(2 bytes),
411+
randomization_seed: $SEED,
400412
}
401-
--> $DIR/debug.rs:37:1
413+
--> $DIR/debug.rs:38:1
402414
|
403415
LL | pub union Y {
404416
| ^^^^^^^^^^^
@@ -421,8 +433,9 @@ error: layout_of(P1) = Layout {
421433
},
422434
max_repr_align: None,
423435
unadjusted_abi_align: Align(1 bytes),
436+
randomization_seed: $SEED,
424437
}
425-
--> $DIR/debug.rs:44:1
438+
--> $DIR/debug.rs:45:1
426439
|
427440
LL | union P1 { x: u32 }
428441
| ^^^^^^^^
@@ -445,8 +458,9 @@ error: layout_of(P2) = Layout {
445458
},
446459
max_repr_align: None,
447460
unadjusted_abi_align: Align(1 bytes),
461+
randomization_seed: $SEED,
448462
}
449-
--> $DIR/debug.rs:48:1
463+
--> $DIR/debug.rs:49:1
450464
|
451465
LL | union P2 { x: (u32, u32) }
452466
| ^^^^^^^^
@@ -469,8 +483,9 @@ error: layout_of(P3) = Layout {
469483
},
470484
max_repr_align: None,
471485
unadjusted_abi_align: Align(1 bytes),
486+
randomization_seed: $SEED,
472487
}
473-
--> $DIR/debug.rs:56:1
488+
--> $DIR/debug.rs:57:1
474489
|
475490
LL | union P3 { x: F32x4 }
476491
| ^^^^^^^^
@@ -493,8 +508,9 @@ error: layout_of(P4) = Layout {
493508
},
494509
max_repr_align: None,
495510
unadjusted_abi_align: Align(1 bytes),
511+
randomization_seed: $SEED,
496512
}
497-
--> $DIR/debug.rs:60:1
513+
--> $DIR/debug.rs:61:1
498514
|
499515
LL | union P4 { x: E }
500516
| ^^^^^^^^
@@ -522,8 +538,9 @@ error: layout_of(P5) = Layout {
522538
},
523539
max_repr_align: None,
524540
unadjusted_abi_align: Align(1 bytes),
541+
randomization_seed: $SEED,
525542
}
526-
--> $DIR/debug.rs:64:1
543+
--> $DIR/debug.rs:65:1
527544
|
528545
LL | union P5 { zst: [u16; 0], byte: u8 }
529546
| ^^^^^^^^
@@ -551,20 +568,21 @@ error: layout_of(MaybeUninit<u8>) = Layout {
551568
},
552569
max_repr_align: None,
553570
unadjusted_abi_align: Align(1 bytes),
571+
randomization_seed: $SEED,
554572
}
555-
--> $DIR/debug.rs:67:1
573+
--> $DIR/debug.rs:68:1
556574
|
557575
LL | type X = std::mem::MaybeUninit<u8>;
558576
| ^^^^^^
559577

560578
error: `#[rustc_layout]` can only be applied to `struct`/`enum`/`union` declarations and type aliases
561-
--> $DIR/debug.rs:70:1
579+
--> $DIR/debug.rs:71:1
562580
|
563581
LL | const C: () = ();
564582
| ^^^^^^^^^^^
565583

566584
error[E0277]: the size for values of type `str` cannot be known at compilation time
567-
--> $DIR/debug.rs:78:19
585+
--> $DIR/debug.rs:79:19
568586
|
569587
LL | type Impossible = (str, str);
570588
| ^^^^^^^^^^ doesn't have a size known at compile-time
@@ -573,13 +591,13 @@ LL | type Impossible = (str, str);
573591
= note: only the last element of a tuple may have a dynamically sized type
574592

575593
error: the type `EmptyUnion` has an unknown layout
576-
--> $DIR/debug.rs:82:1
594+
--> $DIR/debug.rs:83:1
577595
|
578596
LL | union EmptyUnion {}
579597
| ^^^^^^^^^^^^^^^^
580598

581599
error: `#[rustc_layout]` can only be applied to `struct`/`enum`/`union` declarations and type aliases
582-
--> $DIR/debug.rs:74:5
600+
--> $DIR/debug.rs:75:5
583601
|
584602
LL | const C: () = ();
585603
| ^^^^^^^^^^^

‎tests/ui/layout/hexagon-enum.rs‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
//@ compile-flags: --target hexagon-unknown-linux-musl
2+
//@ normalize-stderr: "randomization_seed: \d+" -> "randomization_seed: $$SEED"
23
//@ needs-llvm-components: hexagon
34
//
45
// Verify that the hexagon targets implement the repr(C) for enums correctly.

‎tests/ui/layout/hexagon-enum.stderr‎

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,15 @@ error: layout_of(A) = Layout {
6161
},
6262
max_repr_align: None,
6363
unadjusted_abi_align: Align(1 bytes),
64+
randomization_seed: $SEED,
6465
},
6566
],
6667
},
6768
max_repr_align: None,
6869
unadjusted_abi_align: Align(1 bytes),
70+
randomization_seed: $SEED,
6971
}
70-
--> $DIR/hexagon-enum.rs:16:1
72+
--> $DIR/hexagon-enum.rs:17:1
7173
|
7274
LL | enum A { Apple }
7375
| ^^^^^^
@@ -135,13 +137,15 @@ error: layout_of(B) = Layout {
135137
},
136138
max_repr_align: None,
137139
unadjusted_abi_align: Align(1 bytes),
140+
randomization_seed: $SEED,
138141
},
139142
],
140143
},
141144
max_repr_align: None,
142145
unadjusted_abi_align: Align(1 bytes),
146+
randomization_seed: $SEED,
143147
}
144-
--> $DIR/hexagon-enum.rs:20:1
148+
--> $DIR/hexagon-enum.rs:21:1
145149
|
146150
LL | enum B { Banana = 255, }
147151
| ^^^^^^
@@ -209,13 +213,15 @@ error: layout_of(C) = Layout {
209213
},
210214
max_repr_align: None,
211215
unadjusted_abi_align: Align(2 bytes),
216+
randomization_seed: $SEED,
212217
},
213218
],
214219
},
215220
max_repr_align: None,
216221
unadjusted_abi_align: Align(2 bytes),
222+
randomization_seed: $SEED,
217223
}
218-
--> $DIR/hexagon-enum.rs:24:1
224+
--> $DIR/hexagon-enum.rs:25:1
219225
|
220226
LL | enum C { Chaenomeles = 256, }
221227
| ^^^^^^
@@ -283,13 +289,15 @@ error: layout_of(P) = Layout {
283289
},
284290
max_repr_align: None,
285291
unadjusted_abi_align: Align(4 bytes),
292+
randomization_seed: $SEED,
286293
},
287294
],
288295
},
289296
max_repr_align: None,
290297
unadjusted_abi_align: Align(4 bytes),
298+
randomization_seed: $SEED,
291299
}
292-
--> $DIR/hexagon-enum.rs:28:1
300+
--> $DIR/hexagon-enum.rs:29:1
293301
|
294302
LL | enum P { Peach = 0x1000_0000isize, }
295303
| ^^^^^^
@@ -357,13 +365,15 @@ error: layout_of(T) = Layout {
357365
},
358366
max_repr_align: None,
359367
unadjusted_abi_align: Align(4 bytes),
368+
randomization_seed: $SEED,
360369
},
361370
],
362371
},
363372
max_repr_align: None,
364373
unadjusted_abi_align: Align(4 bytes),
374+
randomization_seed: $SEED,
365375
}
366-
--> $DIR/hexagon-enum.rs:34:1
376+
--> $DIR/hexagon-enum.rs:35:1
367377
|
368378
LL | enum T { Tangerine = TANGERINE as isize }
369379
| ^^^^^^

‎tests/ui/layout/issue-96158-scalarpair-payload-might-be-uninit.rs‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
//@ normalize-stderr: "pref: Align\([1-8] bytes\)" -> "pref: $$PREF_ALIGN"
2+
//@ normalize-stderr: "randomization_seed: \d+" -> "randomization_seed: $$SEED"
23
#![crate_type = "lib"]
34
#![feature(rustc_attrs)]
45

‎tests/ui/layout/issue-96158-scalarpair-payload-might-be-uninit.stderr‎

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ error: layout_of(MissingPayloadField) = Layout {
8383
},
8484
max_repr_align: None,
8585
unadjusted_abi_align: Align(1 bytes),
86+
randomization_seed: $SEED,
8687
},
8788
Layout {
8889
size: Size(1 bytes),
@@ -103,13 +104,15 @@ error: layout_of(MissingPayloadField) = Layout {
103104
},
104105
max_repr_align: None,
105106
unadjusted_abi_align: Align(1 bytes),
107+
randomization_seed: $SEED,
106108
},
107109
],
108110
},
109111
max_repr_align: None,
110112
unadjusted_abi_align: Align(1 bytes),
113+
randomization_seed: $SEED,
111114
}
112-
--> $DIR/issue-96158-scalarpair-payload-might-be-uninit.rs:16:1
115+
--> $DIR/issue-96158-scalarpair-payload-might-be-uninit.rs:17:1
113116
|
114117
LL | pub enum MissingPayloadField {
115118
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -201,6 +204,7 @@ error: layout_of(CommonPayloadField) = Layout {
201204
},
202205
max_repr_align: None,
203206
unadjusted_abi_align: Align(1 bytes),
207+
randomization_seed: $SEED,
204208
},
205209
Layout {
206210
size: Size(2 bytes),
@@ -238,13 +242,15 @@ error: layout_of(CommonPayloadField) = Layout {
238242
},
239243
max_repr_align: None,
240244
unadjusted_abi_align: Align(1 bytes),
245+
randomization_seed: $SEED,
241246
},
242247
],
243248
},
244249
max_repr_align: None,
245250
unadjusted_abi_align: Align(1 bytes),
251+
randomization_seed: $SEED,
246252
}
247-
--> $DIR/issue-96158-scalarpair-payload-might-be-uninit.rs:25:1
253+
--> $DIR/issue-96158-scalarpair-payload-might-be-uninit.rs:26:1
248254
|
249255
LL | pub enum CommonPayloadField {
250256
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -334,6 +340,7 @@ error: layout_of(CommonPayloadFieldIsMaybeUninit) = Layout {
334340
},
335341
max_repr_align: None,
336342
unadjusted_abi_align: Align(1 bytes),
343+
randomization_seed: $SEED,
337344
},
338345
Layout {
339346
size: Size(2 bytes),
@@ -370,13 +377,15 @@ error: layout_of(CommonPayloadFieldIsMaybeUninit) = Layout {
370377
},
371378
max_repr_align: None,
372379
unadjusted_abi_align: Align(1 bytes),
380+
randomization_seed: $SEED,
373381
},
374382
],
375383
},
376384
max_repr_align: None,
377385
unadjusted_abi_align: Align(1 bytes),
386+
randomization_seed: $SEED,
378387
}
379-
--> $DIR/issue-96158-scalarpair-payload-might-be-uninit.rs:33:1
388+
--> $DIR/issue-96158-scalarpair-payload-might-be-uninit.rs:34:1
380389
|
381390
LL | pub enum CommonPayloadFieldIsMaybeUninit {
382391
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -482,6 +491,7 @@ error: layout_of(NicheFirst) = Layout {
482491
},
483492
max_repr_align: None,
484493
unadjusted_abi_align: Align(1 bytes),
494+
randomization_seed: $SEED,
485495
},
486496
Layout {
487497
size: Size(0 bytes),
@@ -502,6 +512,7 @@ error: layout_of(NicheFirst) = Layout {
502512
},
503513
max_repr_align: None,
504514
unadjusted_abi_align: Align(1 bytes),
515+
randomization_seed: $SEED,
505516
},
506517
Layout {
507518
size: Size(0 bytes),
@@ -522,13 +533,15 @@ error: layout_of(NicheFirst) = Layout {
522533
},
523534
max_repr_align: None,
524535
unadjusted_abi_align: Align(1 bytes),
536+
randomization_seed: $SEED,
525537
},
526538
],
527539
},
528540
max_repr_align: None,
529541
unadjusted_abi_align: Align(1 bytes),
542+
randomization_seed: $SEED,
530543
}
531-
--> $DIR/issue-96158-scalarpair-payload-might-be-uninit.rs:41:1
544+
--> $DIR/issue-96158-scalarpair-payload-might-be-uninit.rs:42:1
532545
|
533546
LL | pub enum NicheFirst {
534547
| ^^^^^^^^^^^^^^^^^^^
@@ -634,6 +647,7 @@ error: layout_of(NicheSecond) = Layout {
634647
},
635648
max_repr_align: None,
636649
unadjusted_abi_align: Align(1 bytes),
650+
randomization_seed: $SEED,
637651
},
638652
Layout {
639653
size: Size(0 bytes),
@@ -654,6 +668,7 @@ error: layout_of(NicheSecond) = Layout {
654668
},
655669
max_repr_align: None,
656670
unadjusted_abi_align: Align(1 bytes),
671+
randomization_seed: $SEED,
657672
},
658673
Layout {
659674
size: Size(0 bytes),
@@ -674,13 +689,15 @@ error: layout_of(NicheSecond) = Layout {
674689
},
675690
max_repr_align: None,
676691
unadjusted_abi_align: Align(1 bytes),
692+
randomization_seed: $SEED,
677693
},
678694
],
679695
},
680696
max_repr_align: None,
681697
unadjusted_abi_align: Align(1 bytes),
698+
randomization_seed: $SEED,
682699
}
683-
--> $DIR/issue-96158-scalarpair-payload-might-be-uninit.rs:50:1
700+
--> $DIR/issue-96158-scalarpair-payload-might-be-uninit.rs:51:1
684701
|
685702
LL | pub enum NicheSecond {
686703
| ^^^^^^^^^^^^^^^^^^^^

‎tests/ui/layout/issue-96185-overaligned-enum.rs‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
//@ normalize-stderr: "pref: Align\([1-8] bytes\)" -> "pref: $$PREF_ALIGN"
2+
//@ normalize-stderr: "randomization_seed: \d+" -> "randomization_seed: $$SEED"
23
#![crate_type = "lib"]
34
#![feature(rustc_attrs)]
45

‎tests/ui/layout/issue-96185-overaligned-enum.stderr‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ error: layout_of(Aligned1) = Layout {
5757
Align(8 bytes),
5858
),
5959
unadjusted_abi_align: Align(1 bytes),
60+
randomization_seed: $SEED,
6061
},
6162
Layout {
6263
size: Size(8 bytes),
@@ -79,15 +80,17 @@ error: layout_of(Aligned1) = Layout {
7980
Align(8 bytes),
8081
),
8182
unadjusted_abi_align: Align(1 bytes),
83+
randomization_seed: $SEED,
8284
},
8385
],
8486
},
8587
max_repr_align: Some(
8688
Align(8 bytes),
8789
),
8890
unadjusted_abi_align: Align(1 bytes),
91+
randomization_seed: $SEED,
8992
}
90-
--> $DIR/issue-96185-overaligned-enum.rs:8:1
93+
--> $DIR/issue-96185-overaligned-enum.rs:9:1
9194
|
9295
LL | pub enum Aligned1 {
9396
| ^^^^^^^^^^^^^^^^^
@@ -157,6 +160,7 @@ error: layout_of(Aligned2) = Layout {
157160
Align(1 bytes),
158161
),
159162
unadjusted_abi_align: Align(1 bytes),
163+
randomization_seed: $SEED,
160164
},
161165
Layout {
162166
size: Size(1 bytes),
@@ -179,15 +183,17 @@ error: layout_of(Aligned2) = Layout {
179183
Align(1 bytes),
180184
),
181185
unadjusted_abi_align: Align(1 bytes),
186+
randomization_seed: $SEED,
182187
},
183188
],
184189
},
185190
max_repr_align: Some(
186191
Align(1 bytes),
187192
),
188193
unadjusted_abi_align: Align(1 bytes),
194+
randomization_seed: $SEED,
189195
}
190-
--> $DIR/issue-96185-overaligned-enum.rs:16:1
196+
--> $DIR/issue-96185-overaligned-enum.rs:17:1
191197
|
192198
LL | pub enum Aligned2 {
193199
| ^^^^^^^^^^^^^^^^^

‎tests/ui/layout/randomize.rs‎

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
//@ run-pass
2+
//@ revisions: normal randomize-layout
3+
//@ [randomize-layout]compile-flags: -Zrandomize-layout -Zlayout-seed=2
4+
5+
#![feature(offset_of_enum)]
6+
7+
use std::ptr;
8+
9+
10+
// these types only have their field offsets taken, they're never constructed
11+
#[allow(dead_code)]
12+
pub struct Foo<T>(u32, T, u8);
13+
#[allow(dead_code)]
14+
pub struct Wrapper<T>(T);
15+
#[repr(transparent)]
16+
#[allow(dead_code)]
17+
pub struct TransparentWrapper(u16);
18+
19+
const _: () = {
20+
// Behavior of the current non-randomized implementation, not guaranteed
21+
#[cfg(not(randomize_layout))]
22+
assert!(std::mem::offset_of!(Foo::<u16>, 1) == std::mem::offset_of!(Foo::<Wrapper<u16>>, 1));
23+
24+
// under randomization Foo<T> != Foo<U>
25+
#[cfg(randomize_layout)]
26+
assert!(std::mem::offset_of!(Foo::<u16>, 1) != std::mem::offset_of!(Foo::<Wrapper<u16>>, 1));
27+
28+
// Even transparent wrapper inner types get a different layout since associated type
29+
// specialization could result in the outer type behaving differently depending on the exact
30+
// inner type.
31+
#[cfg(randomize_layout)]
32+
assert!(
33+
std::mem::offset_of!(Foo::<u16>, 1) != std::mem::offset_of!(Foo::<TransparentWrapper>, 1)
34+
);
35+
36+
// Currently all fn pointers are treated interchangably even with randomization. Not guaranteed.
37+
// Associated type specialization could also break this.
38+
assert!(
39+
std::mem::offset_of!(Foo::<fn(u32)>, 1) == std::mem::offset_of!(Foo::<fn() -> usize>, 1)
40+
);
41+
42+
// But subtype coercions must always result in the same layout.
43+
assert!(
44+
std::mem::offset_of!(Foo::<fn(&u32)>, 1) == std::mem::offset_of!(Foo::<fn(&'static u32)>, 1)
45+
);
46+
47+
// Randomization must uphold NPO guarantees
48+
assert!(std::mem::offset_of!(Option::<&usize>, Some.0) == 0);
49+
assert!(std::mem::offset_of!(Result::<&usize, ()>, Ok.0) == 0);
50+
};
51+
52+
#[allow(dead_code)]
53+
struct Unsizable<T: ?Sized>(usize, T);
54+
55+
fn main() {
56+
// offset_of doesn't let us probe the unsized field, check at runtime.
57+
let x = &Unsizable::<[u32; 4]>(0, [0; 4]);
58+
let y: &Unsizable::<[u32]> = x;
59+
60+
// type coercion must not change the layout.
61+
assert_eq!(ptr::from_ref(&x.1).addr(), ptr::from_ref(&y.1).addr());
62+
}

‎tests/ui/layout/thumb-enum.rs‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
//@ compile-flags: --target thumbv8m.main-none-eabihf
2+
//@ normalize-stderr: "randomization_seed: \d+" -> "randomization_seed: $$SEED"
23
//@ needs-llvm-components: arm
34
//
45
// Verify that thumb targets implement the repr(C) for enums correctly.

‎tests/ui/layout/thumb-enum.stderr‎

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,15 @@ error: layout_of(A) = Layout {
6161
},
6262
max_repr_align: None,
6363
unadjusted_abi_align: Align(1 bytes),
64+
randomization_seed: $SEED,
6465
},
6566
],
6667
},
6768
max_repr_align: None,
6869
unadjusted_abi_align: Align(1 bytes),
70+
randomization_seed: $SEED,
6971
}
70-
--> $DIR/thumb-enum.rs:16:1
72+
--> $DIR/thumb-enum.rs:17:1
7173
|
7274
LL | enum A { Apple }
7375
| ^^^^^^
@@ -135,13 +137,15 @@ error: layout_of(B) = Layout {
135137
},
136138
max_repr_align: None,
137139
unadjusted_abi_align: Align(1 bytes),
140+
randomization_seed: $SEED,
138141
},
139142
],
140143
},
141144
max_repr_align: None,
142145
unadjusted_abi_align: Align(1 bytes),
146+
randomization_seed: $SEED,
143147
}
144-
--> $DIR/thumb-enum.rs:20:1
148+
--> $DIR/thumb-enum.rs:21:1
145149
|
146150
LL | enum B { Banana = 255, }
147151
| ^^^^^^
@@ -209,13 +213,15 @@ error: layout_of(C) = Layout {
209213
},
210214
max_repr_align: None,
211215
unadjusted_abi_align: Align(2 bytes),
216+
randomization_seed: $SEED,
212217
},
213218
],
214219
},
215220
max_repr_align: None,
216221
unadjusted_abi_align: Align(2 bytes),
222+
randomization_seed: $SEED,
217223
}
218-
--> $DIR/thumb-enum.rs:24:1
224+
--> $DIR/thumb-enum.rs:25:1
219225
|
220226
LL | enum C { Chaenomeles = 256, }
221227
| ^^^^^^
@@ -283,13 +289,15 @@ error: layout_of(P) = Layout {
283289
},
284290
max_repr_align: None,
285291
unadjusted_abi_align: Align(4 bytes),
292+
randomization_seed: $SEED,
286293
},
287294
],
288295
},
289296
max_repr_align: None,
290297
unadjusted_abi_align: Align(4 bytes),
298+
randomization_seed: $SEED,
291299
}
292-
--> $DIR/thumb-enum.rs:28:1
300+
--> $DIR/thumb-enum.rs:29:1
293301
|
294302
LL | enum P { Peach = 0x1000_0000isize, }
295303
| ^^^^^^
@@ -357,13 +365,15 @@ error: layout_of(T) = Layout {
357365
},
358366
max_repr_align: None,
359367
unadjusted_abi_align: Align(4 bytes),
368+
randomization_seed: $SEED,
360369
},
361370
],
362371
},
363372
max_repr_align: None,
364373
unadjusted_abi_align: Align(4 bytes),
374+
randomization_seed: $SEED,
365375
}
366-
--> $DIR/thumb-enum.rs:34:1
376+
--> $DIR/thumb-enum.rs:35:1
367377
|
368378
LL | enum T { Tangerine = TANGERINE as isize }
369379
| ^^^^^^

‎tests/ui/layout/zero-sized-array-enum-niche.rs‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
//@ normalize-stderr: "pref: Align\([1-8] bytes\)" -> "pref: $$PREF_ALIGN"
2+
//@ normalize-stderr: "randomization_seed: \d+" -> "randomization_seed: $$SEED"
23
#![crate_type = "lib"]
34
#![feature(rustc_attrs)]
45

‎tests/ui/layout/zero-sized-array-enum-niche.stderr‎

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ error: layout_of(Result<[u32; 0], bool>) = Layout {
5959
},
6060
max_repr_align: None,
6161
unadjusted_abi_align: Align(4 bytes),
62+
randomization_seed: $SEED,
6263
},
6364
Layout {
6465
size: Size(2 bytes),
@@ -92,13 +93,15 @@ error: layout_of(Result<[u32; 0], bool>) = Layout {
9293
},
9394
max_repr_align: None,
9495
unadjusted_abi_align: Align(1 bytes),
96+
randomization_seed: $SEED,
9597
},
9698
],
9799
},
98100
max_repr_align: None,
99101
unadjusted_abi_align: Align(4 bytes),
102+
randomization_seed: $SEED,
100103
}
101-
--> $DIR/zero-sized-array-enum-niche.rs:13:1
104+
--> $DIR/zero-sized-array-enum-niche.rs:14:1
102105
|
103106
LL | type AlignedResult = Result<[u32; 0], bool>;
104107
| ^^^^^^^^^^^^^^^^^^
@@ -164,6 +167,7 @@ error: layout_of(MultipleAlignments) = Layout {
164167
},
165168
max_repr_align: None,
166169
unadjusted_abi_align: Align(2 bytes),
170+
randomization_seed: $SEED,
167171
},
168172
Layout {
169173
size: Size(4 bytes),
@@ -188,6 +192,7 @@ error: layout_of(MultipleAlignments) = Layout {
188192
},
189193
max_repr_align: None,
190194
unadjusted_abi_align: Align(4 bytes),
195+
randomization_seed: $SEED,
191196
},
192197
Layout {
193198
size: Size(2 bytes),
@@ -221,13 +226,15 @@ error: layout_of(MultipleAlignments) = Layout {
221226
},
222227
max_repr_align: None,
223228
unadjusted_abi_align: Align(1 bytes),
229+
randomization_seed: $SEED,
224230
},
225231
],
226232
},
227233
max_repr_align: None,
228234
unadjusted_abi_align: Align(4 bytes),
235+
randomization_seed: $SEED,
229236
}
230-
--> $DIR/zero-sized-array-enum-niche.rs:21:1
237+
--> $DIR/zero-sized-array-enum-niche.rs:22:1
231238
|
232239
LL | enum MultipleAlignments {
233240
| ^^^^^^^^^^^^^^^^^^^^^^^
@@ -293,6 +300,7 @@ error: layout_of(Result<[u32; 0], Packed<NonZero<u16>>>) = Layout {
293300
},
294301
max_repr_align: None,
295302
unadjusted_abi_align: Align(4 bytes),
303+
randomization_seed: $SEED,
296304
},
297305
Layout {
298306
size: Size(3 bytes),
@@ -326,13 +334,15 @@ error: layout_of(Result<[u32; 0], Packed<NonZero<u16>>>) = Layout {
326334
},
327335
max_repr_align: None,
328336
unadjusted_abi_align: Align(1 bytes),
337+
randomization_seed: $SEED,
329338
},
330339
],
331340
},
332341
max_repr_align: None,
333342
unadjusted_abi_align: Align(4 bytes),
343+
randomization_seed: $SEED,
334344
}
335-
--> $DIR/zero-sized-array-enum-niche.rs:37:1
345+
--> $DIR/zero-sized-array-enum-niche.rs:38:1
336346
|
337347
LL | type NicheLosesToTagged = Result<[u32; 0], Packed<std::num::NonZero<u16>>>;
338348
| ^^^^^^^^^^^^^^^^^^^^^^^
@@ -402,6 +412,7 @@ error: layout_of(Result<[u32; 0], Packed<U16IsZero>>) = Layout {
402412
},
403413
max_repr_align: None,
404414
unadjusted_abi_align: Align(4 bytes),
415+
randomization_seed: $SEED,
405416
},
406417
Layout {
407418
size: Size(2 bytes),
@@ -435,13 +446,15 @@ error: layout_of(Result<[u32; 0], Packed<U16IsZero>>) = Layout {
435446
},
436447
max_repr_align: None,
437448
unadjusted_abi_align: Align(1 bytes),
449+
randomization_seed: $SEED,
438450
},
439451
],
440452
},
441453
max_repr_align: None,
442454
unadjusted_abi_align: Align(4 bytes),
455+
randomization_seed: $SEED,
443456
}
444-
--> $DIR/zero-sized-array-enum-niche.rs:44:1
457+
--> $DIR/zero-sized-array-enum-niche.rs:45:1
445458
|
446459
LL | type NicheWinsOverTagged = Result<[u32; 0], Packed<U16IsZero>>;
447460
| ^^^^^^^^^^^^^^^^^^^^^^^^

‎tests/ui/repr/repr-c-dead-variants.aarch64-unknown-linux-gnu.stderr‎

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,15 @@ error: layout_of(Univariant) = Layout {
5555
},
5656
max_repr_align: None,
5757
unadjusted_abi_align: Align(4 bytes),
58+
randomization_seed: $SEED,
5859
},
5960
],
6061
},
6162
max_repr_align: None,
6263
unadjusted_abi_align: Align(4 bytes),
64+
randomization_seed: $SEED,
6365
}
64-
--> $DIR/repr-c-dead-variants.rs:38:1
66+
--> $DIR/repr-c-dead-variants.rs:39:1
6567
|
6668
LL | enum Univariant {
6769
| ^^^^^^^^^^^^^^^
@@ -137,6 +139,7 @@ error: layout_of(TwoVariants) = Layout {
137139
},
138140
max_repr_align: None,
139141
unadjusted_abi_align: Align(4 bytes),
142+
randomization_seed: $SEED,
140143
},
141144
Layout {
142145
size: Size(8 bytes),
@@ -173,13 +176,15 @@ error: layout_of(TwoVariants) = Layout {
173176
},
174177
max_repr_align: None,
175178
unadjusted_abi_align: Align(4 bytes),
179+
randomization_seed: $SEED,
176180
},
177181
],
178182
},
179183
max_repr_align: None,
180184
unadjusted_abi_align: Align(4 bytes),
185+
randomization_seed: $SEED,
181186
}
182-
--> $DIR/repr-c-dead-variants.rs:45:1
187+
--> $DIR/repr-c-dead-variants.rs:46:1
183188
|
184189
LL | enum TwoVariants {
185190
| ^^^^^^^^^^^^^^^^
@@ -247,6 +252,7 @@ error: layout_of(DeadBranchHasOtherField) = Layout {
247252
Align(8 bytes),
248253
),
249254
unadjusted_abi_align: Align(8 bytes),
255+
randomization_seed: $SEED,
250256
},
251257
Layout {
252258
size: Size(16 bytes),
@@ -271,15 +277,17 @@ error: layout_of(DeadBranchHasOtherField) = Layout {
271277
},
272278
max_repr_align: None,
273279
unadjusted_abi_align: Align(8 bytes),
280+
randomization_seed: $SEED,
274281
},
275282
],
276283
},
277284
max_repr_align: Some(
278285
Align(8 bytes),
279286
),
280287
unadjusted_abi_align: Align(8 bytes),
288+
randomization_seed: $SEED,
281289
}
282-
--> $DIR/repr-c-dead-variants.rs:57:1
290+
--> $DIR/repr-c-dead-variants.rs:58:1
283291
|
284292
LL | enum DeadBranchHasOtherField {
285293
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

‎tests/ui/repr/repr-c-dead-variants.armebv7r-none-eabi.stderr‎

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,15 @@ error: layout_of(Univariant) = Layout {
5555
},
5656
max_repr_align: None,
5757
unadjusted_abi_align: Align(1 bytes),
58+
randomization_seed: $SEED,
5859
},
5960
],
6061
},
6162
max_repr_align: None,
6263
unadjusted_abi_align: Align(1 bytes),
64+
randomization_seed: $SEED,
6365
}
64-
--> $DIR/repr-c-dead-variants.rs:38:1
66+
--> $DIR/repr-c-dead-variants.rs:39:1
6567
|
6668
LL | enum Univariant {
6769
| ^^^^^^^^^^^^^^^
@@ -137,6 +139,7 @@ error: layout_of(TwoVariants) = Layout {
137139
},
138140
max_repr_align: None,
139141
unadjusted_abi_align: Align(1 bytes),
142+
randomization_seed: $SEED,
140143
},
141144
Layout {
142145
size: Size(2 bytes),
@@ -173,13 +176,15 @@ error: layout_of(TwoVariants) = Layout {
173176
},
174177
max_repr_align: None,
175178
unadjusted_abi_align: Align(1 bytes),
179+
randomization_seed: $SEED,
176180
},
177181
],
178182
},
179183
max_repr_align: None,
180184
unadjusted_abi_align: Align(1 bytes),
185+
randomization_seed: $SEED,
181186
}
182-
--> $DIR/repr-c-dead-variants.rs:45:1
187+
--> $DIR/repr-c-dead-variants.rs:46:1
183188
|
184189
LL | enum TwoVariants {
185190
| ^^^^^^^^^^^^^^^^
@@ -247,6 +252,7 @@ error: layout_of(DeadBranchHasOtherField) = Layout {
247252
Align(8 bytes),
248253
),
249254
unadjusted_abi_align: Align(8 bytes),
255+
randomization_seed: $SEED,
250256
},
251257
Layout {
252258
size: Size(16 bytes),
@@ -271,15 +277,17 @@ error: layout_of(DeadBranchHasOtherField) = Layout {
271277
},
272278
max_repr_align: None,
273279
unadjusted_abi_align: Align(8 bytes),
280+
randomization_seed: $SEED,
274281
},
275282
],
276283
},
277284
max_repr_align: Some(
278285
Align(8 bytes),
279286
),
280287
unadjusted_abi_align: Align(8 bytes),
288+
randomization_seed: $SEED,
281289
}
282-
--> $DIR/repr-c-dead-variants.rs:57:1
290+
--> $DIR/repr-c-dead-variants.rs:58:1
283291
|
284292
LL | enum DeadBranchHasOtherField {
285293
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

‎tests/ui/repr/repr-c-dead-variants.i686-pc-windows-msvc.stderr‎

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,15 @@ error: layout_of(Univariant) = Layout {
5555
},
5656
max_repr_align: None,
5757
unadjusted_abi_align: Align(4 bytes),
58+
randomization_seed: $SEED,
5859
},
5960
],
6061
},
6162
max_repr_align: None,
6263
unadjusted_abi_align: Align(4 bytes),
64+
randomization_seed: $SEED,
6365
}
64-
--> $DIR/repr-c-dead-variants.rs:38:1
66+
--> $DIR/repr-c-dead-variants.rs:39:1
6567
|
6668
LL | enum Univariant {
6769
| ^^^^^^^^^^^^^^^
@@ -137,6 +139,7 @@ error: layout_of(TwoVariants) = Layout {
137139
},
138140
max_repr_align: None,
139141
unadjusted_abi_align: Align(4 bytes),
142+
randomization_seed: $SEED,
140143
},
141144
Layout {
142145
size: Size(8 bytes),
@@ -173,13 +176,15 @@ error: layout_of(TwoVariants) = Layout {
173176
},
174177
max_repr_align: None,
175178
unadjusted_abi_align: Align(4 bytes),
179+
randomization_seed: $SEED,
176180
},
177181
],
178182
},
179183
max_repr_align: None,
180184
unadjusted_abi_align: Align(4 bytes),
185+
randomization_seed: $SEED,
181186
}
182-
--> $DIR/repr-c-dead-variants.rs:45:1
187+
--> $DIR/repr-c-dead-variants.rs:46:1
183188
|
184189
LL | enum TwoVariants {
185190
| ^^^^^^^^^^^^^^^^
@@ -247,6 +252,7 @@ error: layout_of(DeadBranchHasOtherField) = Layout {
247252
Align(8 bytes),
248253
),
249254
unadjusted_abi_align: Align(8 bytes),
255+
randomization_seed: $SEED,
250256
},
251257
Layout {
252258
size: Size(16 bytes),
@@ -271,15 +277,17 @@ error: layout_of(DeadBranchHasOtherField) = Layout {
271277
},
272278
max_repr_align: None,
273279
unadjusted_abi_align: Align(8 bytes),
280+
randomization_seed: $SEED,
274281
},
275282
],
276283
},
277284
max_repr_align: Some(
278285
Align(8 bytes),
279286
),
280287
unadjusted_abi_align: Align(8 bytes),
288+
randomization_seed: $SEED,
281289
}
282-
--> $DIR/repr-c-dead-variants.rs:57:1
290+
--> $DIR/repr-c-dead-variants.rs:58:1
283291
|
284292
LL | enum DeadBranchHasOtherField {
285293
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

‎tests/ui/repr/repr-c-dead-variants.rs‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
// See also: repr-c-int-dead-variants.rs
88

99
//@ normalize-stderr: "pref: Align\([1-8] bytes\)" -> "pref: $$SOME_ALIGN"
10+
//@ normalize-stderr: "randomization_seed: \d+" -> "randomization_seed: $$SEED"
1011

1112
// This test depends on the value of the `c_enum_min_bits` target option.
1213
// As there's no way to actually check it from UI test, we only run this test on a subset of archs.

‎tests/ui/repr/repr-c-dead-variants.x86_64-unknown-linux-gnu.stderr‎

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,15 @@ error: layout_of(Univariant) = Layout {
5555
},
5656
max_repr_align: None,
5757
unadjusted_abi_align: Align(4 bytes),
58+
randomization_seed: $SEED,
5859
},
5960
],
6061
},
6162
max_repr_align: None,
6263
unadjusted_abi_align: Align(4 bytes),
64+
randomization_seed: $SEED,
6365
}
64-
--> $DIR/repr-c-dead-variants.rs:38:1
66+
--> $DIR/repr-c-dead-variants.rs:39:1
6567
|
6668
LL | enum Univariant {
6769
| ^^^^^^^^^^^^^^^
@@ -137,6 +139,7 @@ error: layout_of(TwoVariants) = Layout {
137139
},
138140
max_repr_align: None,
139141
unadjusted_abi_align: Align(4 bytes),
142+
randomization_seed: $SEED,
140143
},
141144
Layout {
142145
size: Size(8 bytes),
@@ -173,13 +176,15 @@ error: layout_of(TwoVariants) = Layout {
173176
},
174177
max_repr_align: None,
175178
unadjusted_abi_align: Align(4 bytes),
179+
randomization_seed: $SEED,
176180
},
177181
],
178182
},
179183
max_repr_align: None,
180184
unadjusted_abi_align: Align(4 bytes),
185+
randomization_seed: $SEED,
181186
}
182-
--> $DIR/repr-c-dead-variants.rs:45:1
187+
--> $DIR/repr-c-dead-variants.rs:46:1
183188
|
184189
LL | enum TwoVariants {
185190
| ^^^^^^^^^^^^^^^^
@@ -247,6 +252,7 @@ error: layout_of(DeadBranchHasOtherField) = Layout {
247252
Align(8 bytes),
248253
),
249254
unadjusted_abi_align: Align(8 bytes),
255+
randomization_seed: $SEED,
250256
},
251257
Layout {
252258
size: Size(16 bytes),
@@ -271,15 +277,17 @@ error: layout_of(DeadBranchHasOtherField) = Layout {
271277
},
272278
max_repr_align: None,
273279
unadjusted_abi_align: Align(8 bytes),
280+
randomization_seed: $SEED,
274281
},
275282
],
276283
},
277284
max_repr_align: Some(
278285
Align(8 bytes),
279286
),
280287
unadjusted_abi_align: Align(8 bytes),
288+
randomization_seed: $SEED,
281289
}
282-
--> $DIR/repr-c-dead-variants.rs:57:1
290+
--> $DIR/repr-c-dead-variants.rs:58:1
283291
|
284292
LL | enum DeadBranchHasOtherField {
285293
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

‎tests/ui/repr/repr-c-int-dead-variants.rs‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
// See also: repr-c-dead-variants.rs
55

66
//@ normalize-stderr: "pref: Align\([1-8] bytes\)" -> "pref: $$SOME_ALIGN"
7+
//@ normalize-stderr: "randomization_seed: \d+" -> "randomization_seed: $$SEED"
78

89
// A simple uninhabited type.
910
enum Void {}

‎tests/ui/repr/repr-c-int-dead-variants.stderr‎

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,15 @@ error: layout_of(UnivariantU8) = Layout {
5555
},
5656
max_repr_align: None,
5757
unadjusted_abi_align: Align(1 bytes),
58+
randomization_seed: $SEED,
5859
},
5960
],
6061
},
6162
max_repr_align: None,
6263
unadjusted_abi_align: Align(1 bytes),
64+
randomization_seed: $SEED,
6365
}
64-
--> $DIR/repr-c-int-dead-variants.rs:14:1
66+
--> $DIR/repr-c-int-dead-variants.rs:15:1
6567
|
6668
LL | enum UnivariantU8 {
6769
| ^^^^^^^^^^^^^^^^^
@@ -137,6 +139,7 @@ error: layout_of(TwoVariantsU8) = Layout {
137139
},
138140
max_repr_align: None,
139141
unadjusted_abi_align: Align(1 bytes),
142+
randomization_seed: $SEED,
140143
},
141144
Layout {
142145
size: Size(2 bytes),
@@ -173,13 +176,15 @@ error: layout_of(TwoVariantsU8) = Layout {
173176
},
174177
max_repr_align: None,
175178
unadjusted_abi_align: Align(1 bytes),
179+
randomization_seed: $SEED,
176180
},
177181
],
178182
},
179183
max_repr_align: None,
180184
unadjusted_abi_align: Align(1 bytes),
185+
randomization_seed: $SEED,
181186
}
182-
--> $DIR/repr-c-int-dead-variants.rs:21:1
187+
--> $DIR/repr-c-int-dead-variants.rs:22:1
183188
|
184189
LL | enum TwoVariantsU8 {
185190
| ^^^^^^^^^^^^^^^^^^
@@ -247,6 +252,7 @@ error: layout_of(DeadBranchHasOtherFieldU8) = Layout {
247252
Align(8 bytes),
248253
),
249254
unadjusted_abi_align: Align(8 bytes),
255+
randomization_seed: $SEED,
250256
},
251257
Layout {
252258
size: Size(16 bytes),
@@ -271,15 +277,17 @@ error: layout_of(DeadBranchHasOtherFieldU8) = Layout {
271277
},
272278
max_repr_align: None,
273279
unadjusted_abi_align: Align(8 bytes),
280+
randomization_seed: $SEED,
274281
},
275282
],
276283
},
277284
max_repr_align: Some(
278285
Align(8 bytes),
279286
),
280287
unadjusted_abi_align: Align(8 bytes),
288+
randomization_seed: $SEED,
281289
}
282-
--> $DIR/repr-c-int-dead-variants.rs:33:1
290+
--> $DIR/repr-c-int-dead-variants.rs:34:1
283291
|
284292
LL | enum DeadBranchHasOtherFieldU8 {
285293
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

‎tests/ui/type/pattern_types/range_patterns.rs‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#![allow(incomplete_features)]
44

55
//@ normalize-stderr: "pref: Align\([1-8] bytes\)" -> "pref: $$SOME_ALIGN"
6+
//@ normalize-stderr: "randomization_seed: \d+" -> "randomization_seed: $$SEED"
67

78
use std::pat::pattern_type;
89

‎tests/ui/type/pattern_types/range_patterns.stderr‎

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,9 @@ error: layout_of(NonZero<u32>) = Layout {
3636
},
3737
max_repr_align: None,
3838
unadjusted_abi_align: Align(4 bytes),
39+
randomization_seed: $SEED,
3940
}
40-
--> $DIR/range_patterns.rs:10:1
41+
--> $DIR/range_patterns.rs:11:1
4142
|
4243
LL | type X = std::num::NonZeroU32;
4344
| ^^^^^^
@@ -73,8 +74,9 @@ error: layout_of((u32) is 1..=) = Layout {
7374
},
7475
max_repr_align: None,
7576
unadjusted_abi_align: Align(4 bytes),
77+
randomization_seed: $SEED,
7678
}
77-
--> $DIR/range_patterns.rs:12:1
79+
--> $DIR/range_patterns.rs:13:1
7880
|
7981
LL | type Y = pattern_type!(u32 is 1..);
8082
| ^^^^^^
@@ -137,6 +139,7 @@ error: layout_of(Option<(u32) is 1..=>) = Layout {
137139
},
138140
max_repr_align: None,
139141
unadjusted_abi_align: Align(1 bytes),
142+
randomization_seed: $SEED,
140143
},
141144
Layout {
142145
size: Size(4 bytes),
@@ -176,13 +179,15 @@ error: layout_of(Option<(u32) is 1..=>) = Layout {
176179
},
177180
max_repr_align: None,
178181
unadjusted_abi_align: Align(4 bytes),
182+
randomization_seed: $SEED,
179183
},
180184
],
181185
},
182186
max_repr_align: None,
183187
unadjusted_abi_align: Align(4 bytes),
188+
randomization_seed: $SEED,
184189
}
185-
--> $DIR/range_patterns.rs:14:1
190+
--> $DIR/range_patterns.rs:15:1
186191
|
187192
LL | type Z = Option<pattern_type!(u32 is 1..)>;
188193
| ^^^^^^
@@ -245,6 +250,7 @@ error: layout_of(Option<NonZero<u32>>) = Layout {
245250
},
246251
max_repr_align: None,
247252
unadjusted_abi_align: Align(1 bytes),
253+
randomization_seed: $SEED,
248254
},
249255
Layout {
250256
size: Size(4 bytes),
@@ -284,13 +290,15 @@ error: layout_of(Option<NonZero<u32>>) = Layout {
284290
},
285291
max_repr_align: None,
286292
unadjusted_abi_align: Align(4 bytes),
293+
randomization_seed: $SEED,
287294
},
288295
],
289296
},
290297
max_repr_align: None,
291298
unadjusted_abi_align: Align(4 bytes),
299+
randomization_seed: $SEED,
292300
}
293-
--> $DIR/range_patterns.rs:16:1
301+
--> $DIR/range_patterns.rs:17:1
294302
|
295303
LL | type A = Option<std::num::NonZeroU32>;
296304
| ^^^^^^
@@ -333,8 +341,9 @@ error: layout_of(NonZeroU32New) = Layout {
333341
},
334342
max_repr_align: None,
335343
unadjusted_abi_align: Align(4 bytes),
344+
randomization_seed: $SEED,
336345
}
337-
--> $DIR/range_patterns.rs:18:1
346+
--> $DIR/range_patterns.rs:19:1
338347
|
339348
LL | struct NonZeroU32New(pattern_type!(u32 is 1..));
340349
| ^^^^^^^^^^^^^^^^^^^^

0 commit comments

Comments
 (0)
This repository has been archived.