Skip to content

Commit 8c07e0a

Browse files
committed
modify commit for check
1 parent ef2538b commit 8c07e0a

File tree

1 file changed

+2
-19
lines changed

1 file changed

+2
-19
lines changed

compiler/rustc_const_eval/src/util/alignment.rs

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -64,25 +64,8 @@ where
6464
}
6565
}
6666

67-
/// Returns the ABI alignment of the *element type* if `ty` is an array/slice,
68-
/// otherwise `None`.
69-
///
70-
/// Soundness note:
71-
/// For any `T`, the ABI alignment of `[T]` (and `[T; N]`) equals that of `T`
72-
/// and does not depend on the length `N`.
73-
/// Proof sketch:
74-
/// (1) From `&[T]` we can obtain `&T` ⇒ align([T]) ≥ align(T).
75-
/// (2) From `&T` we can obtain `&[T; 1]` via `std::array::from_ref`
76-
/// (and thus `&[T]`) ⇒ align(T) ≥ align([T]).
77-
/// Hence `align([T]) == align(T)`.
78-
///
79-
/// Therefore, when `layout_of([T; N])` is unavailable in generic contexts,
80-
/// it is sufficient (and safe) to use `layout_of(T)` for alignment checks.
81-
///
82-
/// Returns:
83-
/// - `Some(align)` if `ty` is `Array(elem, _)` or `Slice(elem)` and
84-
/// `layout_of(elem)` is available;
85-
/// - `None` otherwise (caller should stay conservative).
67+
// For arrays/slices, `align([T]) == align(T)` (independent of length).
68+
// So if layout_of([T; N]) is unavailable, we can fall back to layout_of(T).
8669
fn get_element_alignment<'tcx>(
8770
tcx: TyCtxt<'tcx>,
8871
typing_env: ty::TypingEnv<'tcx>,

0 commit comments

Comments
 (0)