Skip to content

Commit 72927f6

Browse files
committed
Ensure correct aligement of rustc_hir::Lifetime on platforms with lower default alignments.
1 parent edc3841 commit 72927f6

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

compiler/rustc_hir/src/hir.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,11 @@ impl From<Ident> for LifetimeSyntax {
148148
/// `LifetimeSource::OutlivesBound` or `LifetimeSource::PreciseCapturing`
149149
/// — there's no way to "elide" these lifetimes.
150150
#[derive(Debug, Copy, Clone, HashStable_Generic)]
151+
// Raise the aligement to at least 4 bytes - this is relied on in other parts of the compiler(for pointer tagging):
152+
// https://github.com/rust-lang/rust/blob/ce5fdd7d42aba9a2925692e11af2bd39cf37798a/compiler/rustc_data_structures/src/tagged_ptr.rs#L163
153+
// Removing this `repr(4)` will cause the compiler to not build on platforms like `m68k` Linux, where the aligement of u32 and usize is only 2.
154+
// Since `repr(align)` may only raise aligement, this has no effect on platforms where the aligement is already sufficient.
155+
#[repr(align(4))]
151156
pub struct Lifetime {
152157
#[stable_hasher(ignore)]
153158
pub hir_id: HirId,

0 commit comments

Comments
 (0)