pub fn elaborate_struct_ty_fields(
    mut context: FieldContext<'_>,
    surface_fields: &[surface::TypeField],
    report: &mut dyn FnMut(Diagnostic),
) -> Vec<core::TypeField> {
    let mut core_fields = Vec::with_capacity(surface_fields.len());

    for field in surface_fields {
        use std::collections::hash_map::Entry;

        let label = core::Label(field.name.1.clone());
        let field_span = Span::merge(field.name.0, field.term.span());
        let ty = check_term(
            &context.term_context(),
            &field.term,
            &core::Value::Universe(core::Universe::Format),
            report,
        );

        match context.fields.entry(label) {
            Entry::Vacant(entry) => {
                core_fields.push(core::TypeField {
                    doc: field.doc.clone(),
                    start: field_span.start(),
                    name: entry.key().clone(),
                    term: ty,
                });

                entry.insert(field_span);
            }
            Entry::Occupied(entry) => report(diagnostics::field_redeclaration(
                Severity::Error,
                context.file_id,
                entry.key(),
                field_span,
                *entry.get(),
            )),
        }
    }

    core_fields
}
/// Elaborate structure type fields in the surface syntax into structure type
/// fields in the core syntax.
Elaborate structure type fields in the surface syntax into structure type
fields in the core syntax.
Elaborate structure type fields in the surface syntax into structure type fields in the core syntax .
pub fn elaborate_struct_ty_fields(
    mut context: FieldContext<'_>,
    surface_fields: &[surface::TypeField],
    report: &mut dyn FnMut(Diagnostic),
) -> Vec<core::TypeField> {
    let mut core_fields = Vec::with_capacity(surface_fields.len());
    for field in surface_fields {
        use std::collections::hash_map::Entry;
        let label = core::Label(field.name.1.clone());
        let field_span = Span::merge(field.name.0, field.term.span());
        let ty = check_term(
            &context.term_context(),
            &field.term,
            &core::Value::Universe(core::Universe::Format),
            report,
        );
        match context.fields.entry(label) {
            Entry::Vacant(entry) => {
                core_fields.push(core::TypeField {
                    doc: field.doc.clone(),
                    start: field_span.start(),
                    name: entry.key().clone(),
                    term: ty,
                });
                entry.insert(field_span);
            }
            Entry::Occupied(entry) => report(diagnostics::field_redeclaration(
                Severity::Error,
                context.file_id,
                entry.key(),
                field_span,
                *entry.get(),
            )),
        }
    }
    core_fields
}
pub fn elaborate_struct_ty_fields ( mut context : FieldContext < ' _ > , surface_fields : & [ surface :: TypeField ] , report : & mut dyn FnMut ( Diagnostic ) , ) -> Vec < core :: TypeField > { let mut core_fields = Vec :: with_capacity ( surface_fields . len ( ) ) ; for field in surface_fields { use std :: collections :: hash_map :: Entry ; let label = core :: Label ( field . name . 1 . clone ( ) ) ; let field_span = Span :: merge ( field . name . 0 , field . term . span ( ) ) ; let ty = check_term ( & context . term_context ( ) , & field . term , & core :: Value :: Universe ( core :: Universe :: Format ) , report , ) ; match context . fields . entry ( label ) { Entry :: Vacant ( entry ) => { core_fields . push ( core :: TypeField { doc : field . doc . clone ( ) , start : field_span . start ( ) , name : entry . key ( ) . clone ( ) , term : ty , } ) ; entry . insert ( field_span ) ; } Entry :: Occupied ( entry ) => report ( diagnostics :: field_redeclaration ( Severity :: Error , context . file_id , entry . key ( ) , field_span , * entry . get ( ) , ) ) , } } core_fields }
Elaborate structure type fields in the surface syntax into structure type
fields in the core syntax.
Elaborate structure type fields in the surface syntax into structure type fields in the core syntax .
context
FieldContext<'_>
surface_fields
&[surface::TypeField]
report
&mut dyn FnMut(Diagnostic)
context
FieldContext<'_>
surface_fields
&[surface::TypeField]
report
&mut dyn FnMut(Diagnostic)