Skip to content

Commit ee49e95

Browse files
committed
doc comments for layout components
1 parent 3c4590f commit ee49e95

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

src/librustc_target/abi/mod.rs

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -871,8 +871,26 @@ impl Niche {
871871

872872
#[derive(PartialEq, Eq, Hash, Debug, HashStable_Generic)]
873873
pub struct LayoutDetails {
874-
pub variants: Variants,
874+
/// Says where the fields are located.
875+
/// Primitives and fieldless enums appear as unions without fields.
875876
pub fields: FieldPlacement,
877+
878+
/// Encodes information about multi-variant layouts.
879+
/// Even with `Multiple` variants, a layout can still have fields! Those are then
880+
/// shared between all variants. One of them will be the discriminant,
881+
/// but e.g. generators can have more.
882+
///
883+
/// A layout-guided recursive descent must first look at all the fields,
884+
/// and only then check if this is a multi-variant layout and if so, proceed
885+
/// with the active variant.
886+
pub variants: Variants,
887+
888+
/// The `abi` defines how this data is passed between functions, and it defines
889+
/// value restrictions via `valid_range`.
890+
///
891+
/// Note that this is entirely orthogonal to the recursive structrue defined by
892+
/// `variants` and `fields`; for example, `ManuallyDrop<Result<isize, isize>>` has
893+
/// `Abi::ScalarPair`! So, having a non-`Aggregate` `abi` should not stop a recursive descent.
876894
pub abi: Abi,
877895

878896
/// The leaf scalar with the largest number of invalid values

0 commit comments

Comments
 (0)