fn check_arg_app_mode<'arg, 'file>(
    concrete_arg: &'arg Arg<'file>,
    expected_app_mode: &AppMode,
) -> Result<Cow<'arg, Term<'file>>, Diagnostic<FileSpan>> {
    match (concrete_arg, expected_app_mode) {
        (Arg::Explicit(concrete_arg), AppMode::Explicit) => Ok(Cow::Borrowed(concrete_arg)),
        (Arg::Implicit(_, intro_label, concrete_arg), AppMode::Implicit(ty_label))
        | (Arg::Instance(_, intro_label, concrete_arg), AppMode::Instance(ty_label))
            if intro_label.slice == ty_label.0 =>
        {
            match concrete_arg {
                None => Ok(Cow::Owned(Term::Var(intro_label.clone()))),
                Some(concrete_arg) => Ok(Cow::Borrowed(concrete_arg)),
            }
        },
        (_, AppMode::Implicit(ty_label)) => {
            let message = "inference of implicit arguments is not yet supported";
            Err(Diagnostic::new_error(message).with_label(
                DiagnosticLabel::new_primary(concrete_arg.span()).with_message(format!(
                    "add the explicit argument `{{{} = ..}}` here",
                    ty_label,
                )),
            ))
        },
        (_, AppMode::Instance(ty_label)) => {
            let message = "inference of instance arguments is not yet supported";
            Err(Diagnostic::new_error(message).with_label(
                DiagnosticLabel::new_primary(concrete_arg.span()).with_message(format!(
                    "add the explicit argument `{{{{{} = ..}}}}` here",
                    ty_label,
                )),
            ))
        },
        (Arg::Implicit(span, _, _), AppMode::Explicit)
        | (Arg::Instance(span, _, _), AppMode::Explicit) => {
            let message = "unexpected argument";
            Err(Diagnostic::new_error(message).with_label(
                DiagnosticLabel::new_primary(*span).with_message("this argument is not needed"),
            ))
        },
    }
}
/// Check that a given argument matches the expected application mode, and
/// return the term inside it.
Check that a given argument matches the expected application mode, and
return the term inside it.
Check that a given argument matches the expected application mode and return the term inside it .
fn check_arg_app_mode<'arg, 'file>(
    concrete_arg: &'arg Arg<'file>,
    expected_app_mode: &AppMode,
) -> Result<Cow<'arg, Term<'file>>, Diagnostic<FileSpan>> {
    match (concrete_arg, expected_app_mode) {
        (Arg::Explicit(concrete_arg), AppMode::Explicit) => Ok(Cow::Borrowed(concrete_arg)),
        (Arg::Implicit(_, intro_label, concrete_arg), AppMode::Implicit(ty_label))
        | (Arg::Instance(_, intro_label, concrete_arg), AppMode::Instance(ty_label))
            if intro_label.slice == ty_label.0 =>
        {
            match concrete_arg {
                None => Ok(Cow::Owned(Term::Var(intro_label.clone()))),
                Some(concrete_arg) => Ok(Cow::Borrowed(concrete_arg)),
            }
        },
        (_, AppMode::Implicit(ty_label)) => {
            let message = "inference of implicit arguments is not yet supported";
            Err(Diagnostic::new_error(message).with_label(
                DiagnosticLabel::new_primary(concrete_arg.span()).with_message(format!(
                    "add the explicit argument `{{{} = ..}}` here",
                    ty_label,
                )),
            ))
        },
        (_, AppMode::Instance(ty_label)) => {
            let message = "inference of instance arguments is not yet supported";
            Err(Diagnostic::new_error(message).with_label(
                DiagnosticLabel::new_primary(concrete_arg.span()).with_message(format!(
                    "add the explicit argument `{{{{{} = ..}}}}` here",
                    ty_label,
                )),
            ))
        },
        (Arg::Implicit(span, _, _), AppMode::Explicit)
        | (Arg::Instance(span, _, _), AppMode::Explicit) => {
            let message = "unexpected argument";
            Err(Diagnostic::new_error(message).with_label(
                DiagnosticLabel::new_primary(*span).with_message("this argument is not needed"),
            ))
        },
    }
}
fn check_arg_app_mode < ' arg , ' file > ( concrete_arg : & ' arg Arg < ' file > , expected_app_mode : & AppMode , ) -> Result < Cow < ' arg , Term < ' file > > , Diagnostic < FileSpan > > { match ( concrete_arg , expected_app_mode ) { ( Arg :: Explicit ( concrete_arg ) , AppMode :: Explicit ) => Ok ( Cow :: Borrowed ( concrete_arg ) ) , ( Arg :: Implicit ( _ , intro_label , concrete_arg ) , AppMode :: Implicit ( ty_label ) ) | ( Arg :: Instance ( _ , intro_label , concrete_arg ) , AppMode :: Instance ( ty_label ) ) if intro_label . slice == ty_label . 0 => { match concrete_arg { None => Ok ( Cow :: Owned ( Term :: Var ( intro_label . clone ( ) ) ) ) , Some ( concrete_arg ) => Ok ( Cow :: Borrowed ( concrete_arg ) ) , } } , ( _ , AppMode :: Implicit ( ty_label ) ) => { let message = " " ; Err ( Diagnostic :: new_error ( message ) . with_label ( DiagnosticLabel :: new_primary ( concrete_arg . span ( ) ) . with_message ( format ! ( " " ty_label ) ) , ) ) } , ( _ , AppMode :: Instance ( ty_label ) ) => { let message = " " ; Err ( Diagnostic :: new_error ( message ) . with_label ( DiagnosticLabel :: new_primary ( concrete_arg . span ( ) ) . with_message ( format ! ( " " ty_label ) ) , ) ) } , ( Arg :: Implicit ( span , _ , _ ) , AppMode :: Explicit ) | ( Arg :: Instance ( span , _ , _ ) , AppMode :: Explicit ) => { let message = " " ; Err ( Diagnostic :: new_error ( message ) . with_label ( DiagnosticLabel :: new_primary ( * span ) . with_message ( " " ) , ) ) } , } }
Check that a given argument matches the expected application mode, and
return the term inside it.
Check that a given argument matches the expected application mode and return the term inside it .
concrete_arg
&'arg Arg<'file>
expected_app_mode
&AppMode