mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-11-17 18:57:04 +00:00
Rollup merge of #133088 - the8472:randomize-me-harder, r=workingjubilee
`-Zrandomize-layout` harder. `Foo<T> != Foo<U>` Tracking issue: #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.
This commit is contained in:
commit
42d386f559
1 changed files with 4 additions and 0 deletions
|
|
@ -197,6 +197,7 @@ fn layout_of_simd_ty(
|
|||
align,
|
||||
max_repr_align: None,
|
||||
unadjusted_abi_align: align.abi,
|
||||
randomization_seed: 0,
|
||||
}))
|
||||
}
|
||||
|
||||
|
|
@ -313,6 +314,7 @@ pub fn layout_of_ty_query(
|
|||
size,
|
||||
max_repr_align: None,
|
||||
unadjusted_abi_align: element.align.abi,
|
||||
randomization_seed: 0,
|
||||
}
|
||||
}
|
||||
TyKind::Slice(element) => {
|
||||
|
|
@ -326,6 +328,7 @@ pub fn layout_of_ty_query(
|
|||
size: Size::ZERO,
|
||||
max_repr_align: None,
|
||||
unadjusted_abi_align: element.align.abi,
|
||||
randomization_seed: 0,
|
||||
}
|
||||
}
|
||||
TyKind::Str => Layout {
|
||||
|
|
@ -337,6 +340,7 @@ pub fn layout_of_ty_query(
|
|||
size: Size::ZERO,
|
||||
max_repr_align: None,
|
||||
unadjusted_abi_align: dl.i8_align.abi,
|
||||
randomization_seed: 0,
|
||||
},
|
||||
// Potentially-wide pointers.
|
||||
TyKind::Ref(_, _, pointee) | TyKind::Raw(_, pointee) => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue