You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: id.rs
    path of file: ./repos/prisma-engines/psl/parser-database/src/attributes
    
    the code of the file until where you have to start completion: use super::{FieldResolutionError, FieldResolvingSetup};
use crate::{
    ast::{self, WithName, WithSpan},
    attributes::resolve_field_array_with_args,
    coerce,
    context::Context,
    types::{FieldWithArgs, IdAttribute, IndexFieldPath, ModelAttributes, ScalarField, SortOrder},
    DatamodelError, ScalarFieldId, StringId,
};
use std::borrow::Cow;

/// @@id on models
pub(super) fn model(model_data: &mut ModelAttributes, model_id: ast::ModelId, ctx: &mut Context<'_>) {
    let attr = ctx.current_attribute();
    let fields = match ctx.visit_default_arg("fields") {
        Ok(value) => value,
        Err(err) => return ctx.push_error(err),
    };

    let resolving = FieldResolvingSetup::OnlyTopLevel;

    let resolved_fields = match resolve_field_array_with_args(fields, attr.span, model_id, resolving, ctx) {
        Ok(fields) => fields,
        Err(FieldResolutionError::AlreadyDealtWith) => return,
        Err(FieldResolutionError::ProblematicFields {
            unknown_fields: unresolvable_fields,
            relation_fields,
        }) => {
            if !unresolvable_fields.is_empty() {
                let fields_str = unresolvable_fields
                    .into_iter()
                    .map(|(top_id, field_name)| match top_id {
                        ast::TopId::CompositeType(ctid) => {
                            let ct_name = &ctx.ast[ctid].name();

                            Cow::from(format!("{field_name} in type {ct_name}"))
                        }
                        ast::TopId::Model(_) => Cow::from(field_name),
                        _ => unreachable!(),
                    })
                    .collect::<Vec<_>>()
                    .join(", ");

                let msg = format!("The multi field id declaration refers to the unknown fields {fields_str}.");
                let error =
                    DatamodelError::new_model_validation_error(&msg, "model", ctx.ast[model_id].name(), fields.span());

                ctx.push_error(error);
            }

            if !relation_fields.is_empty() {
                let field_names = relation_fields
                    .iter()
                    .map(|(f, _)| f.name())
                    .collect::<Vec<_>>()
                    .join(", ");

                let msg = format!("The id definition refe
    
pub(super) fn model(model_data: &mut ModelAttributes, model_id: ast::ModelId, ctx: &mut Context<'_>) {
    let attr = ctx.current_attribute();
    let fields = match ctx.visit_default_arg("fields") {
        Ok(value) => value,
        Err(err) => return ctx.push_error(err),
    };

    let resolving = FieldResolvingSetup::OnlyTopLevel;

    let resolved_fields = match resolve_field_array_with_args(fields, attr.span, model_id, resolving, ctx) {
        Ok(fields) => fields,
        Err(FieldResolutionError::AlreadyDealtWith) => return,
        Err(FieldResolutionError::ProblematicFields {
            unknown_fields: unresolvable_fields,
            relation_fields,
        }) => {
            if !unresolvable_fields.is_empty() {
                let fields_str = unresolvable_fields
                    .into_iter()
                    .map(|(top_id, field_name)| match top_id {
                        ast::TopId::CompositeType(ctid) => {
                            let ct_name = &ctx.ast[ctid].name();

                            Cow::from(format!("{field_name} in type {ct_name}"))
                        }
                        ast::TopId::Model(_) => Cow::from(field_name),
                        _ => unreachable!(),
                    })
                    .collect::<Vec<_>>()
                    .join(", ");

                let msg = format!("The multi field id declaration refers to the unknown fields {fields_str}.");
                let error =
                    DatamodelError::new_model_validation_error(&msg, "model", ctx.ast[model_id].name(), fields.span());

                ctx.push_error(error);
            }

            if !relation_fields.is_empty() {
                let field_names = relation_fields
                    .iter()
                    .map(|(f, _)| f.name())
                    .collect::<Vec<_>>()
                    .join(", ");

                let msg = format!("The id definition refers to the relation fields {field_names}. ID definitions must reference only scalar fields.");

                ctx.push_error(DatamodelError::new_model_validation_error(
                    &msg,
                    "model",
                    ctx.ast[model_id].name(),
                    attr.span,
                ));
            }

            return;
        }
    };

    let ast_model = &ctx.ast[model_id];

    // ID attribute fields must reference only required fields.
    let fields_that_are_not_required: Vec<&str> = resolved_fields
        .iter()
        .filter_map(|field| match field.path.field_in_index() {
            either::Either::Left(id) => {
                let ScalarField { model_id, field_id, .. } = ctx.types[id];
                let field = &ctx.ast[model_id][field_id];

                if field.arity.is_required() {
                    None
                } else {
                    Some(field.name())
                }
            }
            either::Either::Right((ctid, field_id)) => {
                let field = &ctx.ast[ctid][field_id];

                if field.arity.is_required() {
                    None
                } else {
                    Some(field.name())
                }
            }
        })
        .collect();

    if !fields_that_are_not_required.is_empty() {
        ctx.push_error(DatamodelError::new_model_validation_error(
            &format!(
                "The id definition refers to the optional fields {}. ID definitions must reference only required fields.",
                fields_that_are_not_required.join(", ")
            ),
            "model",
            ast_model.name(),
            attr.span,
        ))
    }

    if model_data.primary_key.is_some() {
        ctx.push_error(DatamodelError::new_model_validation_error(
            "Each model must have at most one id criteria. You can't have `@id` and `@@id` at the same time.",
            "model",
            ast_model.name(),
            ast_model.span(),
        ))
    }

    let (name, mapped_name) = {
        let mapped_name = primary_key_mapped_name(ctx);
        let name = super::get_name_argument(ctx);

        if let Some(name) = name {
            super::validate_client_name(attr.span(), ast_model.name(), name, "@@id", ctx);
        }

        (name, mapped_name)
    };

    let clustered = super::validate_clustering_setting(ctx);

    model_data.primary_key = Some(IdAttribute {
        name,
        source_attribute: ctx.current_attribute_id(),
        mapped_name,
        fields: resolved_fields,
        source_field: None,
        clustered,
    });
}