fn describe_enum_variant(
    cx: &CodegenCx<'ll, 'tcx>,
    layout: layout::TyLayout<'tcx>,
    variant: &'tcx ty::VariantDef,
    discriminant_info: EnumDiscriminantInfo<'ll>,
    containing_scope: &'ll DIScope,
    span: Span,
) -> (&'ll DICompositeType, MemberDescriptionFactory<'ll, 'tcx>) {
    let variant_name = variant.name.as_str();
    let unique_type_id = debug_context(cx).type_map
                                          .borrow_mut()
                                          .get_unique_type_id_of_enum_variant(
                                              cx,
                                              layout.ty,
                                              &variant_name);

    let metadata_stub = create_struct_stub(cx,
                                           layout.ty,
                                           &variant_name,
                                           unique_type_id,
                                           Some(containing_scope));

    // If this is not a univariant enum, there is also the discriminant field.
    let (discr_offset, discr_arg) = match discriminant_info {
        RegularDiscriminant(_) => {
            // We have the layout of an enum variant, we need the layout of the outer enum
            let enum_layout = cx.layout_of(layout.ty);
            (Some(enum_layout.fields.offset(0)),
             Some(("RUST$ENUM$DISR".to_string(), enum_layout.field(cx, 0).ty)))
        }
        _ => (None, None),
    };
    let offsets = discr_offset.into_iter().chain((0..layout.fields.count()).map(|i| {
        layout.fields.offset(i)
    })).collect();

    // Build an array of (field name, field type) pairs to be captured in the factory closure.
    let args = discr_arg.into_iter().chain((0..layout.fields.count()).map(|i| {
        let name = if variant.ctor_kind == CtorKind::Fn {
            format!("__{}", i)
        } else {
            variant.fields[i].ident.to_string()
        };
        (name, layout.field(cx, i).ty)
    })).collect();

    let member_description_factory =
        VariantMDF(VariantMemberDescriptionFactory {
            offsets,
            args,
            discriminant_type_metadata: match discriminant_info {
                RegularDiscriminant(discriminant_type_metadata) => {
                    Some(discriminant_type_metadata)
                }
                _ => None
            },
            span,
        });

    (metadata_stub, member_description_factory)
}
// Returns a tuple of (1) type_metadata_stub of the variant, (2) the llvm_type
// of the variant, and (3) a MemberDescriptionFactory for producing the
// descriptions of the fields of the variant. This is a rudimentary version of a
// full RecursiveTypeDescription.
Returns a tuple of (1) type_metadata_stub of the variant, (2) the llvm_type
of the variant, and (3) a MemberDescriptionFactory for producing the
descriptions of the fields of the variant. This is a rudimentary version of a
full RecursiveTypeDescription.
Returns a tuple of ( 1 ) type_metadata_stub of the variant ( 2 ) the llvm_type of the variant and ( 3 ) a MemberDescriptionFactory for producing the descriptions of the fields of the variant . This is a rudimentary version of a full RecursiveTypeDescription .
fn describe_enum_variant(
    cx: &CodegenCx<'ll, 'tcx>,
    layout: layout::TyLayout<'tcx>,
    variant: &'tcx ty::VariantDef,
    discriminant_info: EnumDiscriminantInfo<'ll>,
    containing_scope: &'ll DIScope,
    span: Span,
) -> (&'ll DICompositeType, MemberDescriptionFactory<'ll, 'tcx>) {
    let variant_name = variant.name.as_str();
    let unique_type_id = debug_context(cx).type_map
                                          .borrow_mut()
                                          .get_unique_type_id_of_enum_variant(
                                              cx,
                                              layout.ty,
                                              &variant_name);
    let metadata_stub = create_struct_stub(cx,
                                           layout.ty,
                                           &variant_name,
                                           unique_type_id,
                                           Some(containing_scope));
    // If this is not a univariant enum, there is also the discriminant field.
    let (discr_offset, discr_arg) = match discriminant_info {
        RegularDiscriminant(_) => {
            // We have the layout of an enum variant, we need the layout of the outer enum
            let enum_layout = cx.layout_of(layout.ty);
            (Some(enum_layout.fields.offset(0)),
             Some(("RUST$ENUM$DISR".to_string(), enum_layout.field(cx, 0).ty)))
        }
        _ => (None, None),
    };
    let offsets = discr_offset.into_iter().chain((0..layout.fields.count()).map(|i| {
        layout.fields.offset(i)
    })).collect();
    // Build an array of (field name, field type) pairs to be captured in the factory closure.
    let args = discr_arg.into_iter().chain((0..layout.fields.count()).map(|i| {
        let name = if variant.ctor_kind == CtorKind::Fn {
            format!("__{}", i)
        } else {
            variant.fields[i].ident.to_string()
        };
        (name, layout.field(cx, i).ty)
    })).collect();
    let member_description_factory =
        VariantMDF(VariantMemberDescriptionFactory {
            offsets,
            args,
            discriminant_type_metadata: match discriminant_info {
                RegularDiscriminant(discriminant_type_metadata) => {
                    Some(discriminant_type_metadata)
                }
                _ => None
            },
            span,
        });
    (metadata_stub, member_description_factory)
}
fn describe_enum_variant ( cx : & CodegenCx < ' ll , ' tcx > , layout : layout :: TyLayout < ' tcx > , variant : & ' tcx ty :: VariantDef , discriminant_info : EnumDiscriminantInfo < ' ll > , containing_scope : & ' ll DIScope , span : Span , ) -> ( & ' ll DICompositeType , MemberDescriptionFactory < ' ll , ' tcx > ) { let variant_name = variant . name . as_str ( ) ; let unique_type_id = debug_context ( cx ) . type_map . borrow_mut ( ) . get_unique_type_id_of_enum_variant ( cx , layout . ty , & variant_name ) ; let metadata_stub = create_struct_stub ( cx , layout . ty , & variant_name , unique_type_id , Some ( containing_scope ) ) ; // If this is not a univariant enum, there is also the discriminant field. let ( discr_offset , discr_arg ) = match discriminant_info { RegularDiscriminant ( _ ) => { // We have the layout of an enum variant, we need the layout of the outer enum let enum_layout = cx . layout_of ( layout . ty ) ; ( Some ( enum_layout . fields . offset ( 0 ) ) , Some ( ( " " . to_string ( ) , enum_layout . field ( cx , 0 ) . ty ) ) ) } _ => ( None , None ) , } ; let offsets = discr_offset . into_iter ( ) . chain ( ( 0 .. layout . fields . count ( ) ) . map ( | i | { layout . fields . offset ( i ) } ) ) . collect ( ) ; // Build an array of (field name, field type) pairs to be captured in the factory closure. let args = discr_arg . into_iter ( ) . chain ( ( 0 .. layout . fields . count ( ) ) . map ( | i | { let name = if variant . ctor_kind == CtorKind :: Fn { format ! ( " " i ) } else { variant . fields [ i ] . ident . to_string ( ) } ; ( name , layout . field ( cx , i ) . ty ) } ) ) . collect ( ) ; let member_description_factory = VariantMDF ( VariantMemberDescriptionFactory { offsets , args , discriminant_type_metadata : match discriminant_info { RegularDiscriminant ( discriminant_type_metadata ) => { Some ( discriminant_type_metadata ) } _ => None } , span , } ) ; ( metadata_stub , member_description_factory ) }
Returns a tuple of (1) type_metadata_stub of the variant, (2) the llvm_type
of the variant, and (3) a MemberDescriptionFactory for producing the
descriptions of the fields of the variant.
Returns a tuple of ( 1 ) type_metadata_stub of the variant ( 2 ) the llvm_type of the variant and ( 3 ) a MemberDescriptionFactory for producing the descriptions of the fields of the variant .
cx
&CodegenCx<'ll, 'tcx>
layout
layout::TyLayout<'tcx>
variant
&'tcx ty::VariantDef
discriminant_info
EnumDiscriminantInfo<'ll>
containing_scope
&'ll DIScope
span
Span
cx
&CodegenCx<'ll, 'tcx>
layout
layout::TyLayout<'tcx>
variant
&'tcx ty::VariantDef
discriminant_info
EnumDiscriminantInfo<'ll>
containing_scope
&'ll DIScope
span
Span