Skip to main content

build_method_precondition_checks

Function build_method_precondition_checks 

Source
pub(crate) fn build_method_precondition_checks(
    inputs: &Punctuated<FnArg, Comma>,
    per_param: &HashMap<String, ParamAttrs>,
    coerce_all: bool,
    method_level: Option<bool>,
    impl_level: Option<bool>,
    call: Option<&str>,
) -> Vec<String>
Expand description

Build the R-side precondition guard lines for a parameter list, given its per-param map (match_arg/choices skips, inherits / not_inherits / no_na checks, each parameter’s own preconditions decision), whether coerce is active for the whole method, and the method’s and impl block’s preconditions / no_preconditions (method_level, impl_level). Each parameter keeps its type-derived checks as crate::r_preconditions::resolve_type_checks decides, under the crate default and the no-preconditions-default feature; the named checks stay either way.

Neither impl methods nor trait methods carry a per-param coerce flag (only function-wide coerce, see ParsedMethod::per_param docs), so coerce_params is always empty here. call is the call every failing guard is attributed to (PreconditionOutput::guards): None for the method’s own frame, environment() for an S3 method (#1851). Shared by MethodContext::precondition_checks, TraitMethodContext::precondition_checks and the R6 active-binding setter.