Skip to content

Commit d4745f8

Browse files
committed
libsyntax_pos: Don't use packed attribute for Span on sparc64/v9
Due the limitation that #[derive(...)] on #[repr(packed)] structs does not guarantee proper alignment of the compiler-generated impls is not guaranteed (#39696), the change in #44646 to compress Spans results in the compiler generating code with unaligned access. Until #39696 has been fixed, the issue can be worked around by not using the packed attribute on sparc64 and sparcv9 on the Span struct. Fixes: #45509
1 parent 7402866 commit d4745f8

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/libsyntax_pos/span_encoding.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,10 @@ use std::cell::RefCell;
2525
/// The primary goal of `Span` is to be as small as possible and fit into other structures
2626
/// (that's why it uses `packed` as well). Decoding speed is the second priority.
2727
/// See `SpanData` for the info on span fields in decoded representation.
28+
29+
/// FIXME: Don't use packed attribute on sparc64/v9, see: #45509
2830
#[derive(Clone, Copy, PartialEq, Eq, Hash)]
29-
#[repr(packed)]
31+
#[cfg_attr(not(any(target_arch = "sparc64", target_arch = "sparcv9")), repr(packed))]
3032
pub struct Span(u32);
3133

3234
/// Dummy span, both position and length are zero, syntax context is zero as well.

0 commit comments

Comments
 (0)