Skip to content

Commit d763e79

Browse files
authored
Unrolled build for rust-lang#130384
Rollup merge of rust-lang#130384 - workingjubilee:document-what-abi-and-pref-align-is, r=compiler-errors compiler: Document AbiAndPrefAlign The mere existence of this struct is confusing, and the second field doubly so. It's easy to mistake the "preferred" alignment as semantically relevant somehow. Insofar as I am aware, it is not, and certainly not for Rust code.
2 parents 8c2c9a9 + 7b02be8 commit d763e79

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

compiler/rustc_abi/src/lib.rs

+8
Original file line numberDiff line numberDiff line change
@@ -781,6 +781,14 @@ impl Align {
781781
}
782782

783783
/// A pair of alignments, ABI-mandated and preferred.
784+
///
785+
/// The "preferred" alignment is an LLVM concept that is virtually meaningless to Rust code:
786+
/// it is not exposed semantically to programmers nor can they meaningfully affect it.
787+
/// The only concern for us is that preferred alignment must not be less than the mandated alignment
788+
/// and thus in practice the two values are almost always identical.
789+
///
790+
/// An example of a rare thing actually affected by preferred alignment is aligning of statics.
791+
/// It is of effectively no consequence for layout in structs and on the stack.
784792
#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)]
785793
#[cfg_attr(feature = "nightly", derive(HashStable_Generic))]
786794
pub struct AbiAndPrefAlign {

0 commit comments

Comments
 (0)