File tree Expand file tree Collapse file tree 1 file changed +6
-3
lines changed
compiler/rustc_const_eval/src/util Expand file tree Collapse file tree 1 file changed +6
-3
lines changed Original file line number Diff line number Diff line change 4646 }
4747 }
4848 Err ( _) => {
49- // Soundness-critical: this may return false positives (reporting potential misalignment),
50- // but must not return false negatives. When layout is unavailable, we stay conservative
51- // except for arrays of u8/i8 whose ABI alignment is provably 1.
49+ // Soundness: For any `T`, the ABI alignment requirement of `[T]` equals that of `T`.
50+ // Proof sketch:
51+ // (1) From `&[T]` we can obtain `&T`, hence align([T]) >= align(T).
52+ // (2) Using `std::array::from_ref(&T)` we can obtain `&[T; 1]` (and thus `&[T]`),
53+ // hence align(T) >= align([T]).
54+ // Therefore align([T]) == align(T). Length does not affect alignment.
5255
5356 // Try to determine alignment from the type structure
5457 if let Some ( element_align) = get_element_alignment ( tcx, ty) {
You can’t perform that action at this time.
0 commit comments