Skip to content

Commit

Permalink
libsyntax_pos: Don't use packed attribute for Span on sparc64/v9
Browse files Browse the repository at this point in the history
Due the limitation that #[derive(...)] on #[repr(packed)] structs
does not guarantee proper alignment of the compiler-generated
impls is not guaranteed (rust-lang#39696), the change in rust-lang#44646 to compress
Spans results in the compiler generating code with unaligned access.

Until rust-lang#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: rust-lang#45509
  • Loading branch information
glaubitz committed Nov 1, 2017
1 parent 7402866 commit d4745f8
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/libsyntax_pos/span_encoding.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,10 @@ use std::cell::RefCell;
/// The primary goal of `Span` is to be as small as possible and fit into other structures
/// (that's why it uses `packed` as well). Decoding speed is the second priority.
/// See `SpanData` for the info on span fields in decoded representation.
/// FIXME: Don't use packed attribute on sparc64/v9, see: #45509
#[derive(Clone, Copy, PartialEq, Eq, Hash)]
#[repr(packed)]
#[cfg_attr(not(any(target_arch = "sparc64", target_arch = "sparcv9")), repr(packed))]
pub struct Span(u32);

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

0 comments on commit d4745f8

Please sign in to comment.