Skip to main content

finalize_method_param_attrs

Function finalize_method_param_attrs 

Source
pub(crate) fn finalize_method_param_attrs(
    per_param: &mut HashMap<String, ParamAttrs>,
    inputs: &Punctuated<FnArg, Comma>,
    markers: &[(String, Vec<ParamMarker>)],
    defaults: &HashMap<String, String>,
    span: Span,
) -> Result<()>
Expand description

Check an impl or trait method’s per-parameter attributes against its signature, now that it is known. Every parameter a method-level match_arg(...) / choices(...) / no_default(...) / inherits(...) / not_inherits(...) / no_na(...) / preconditions(...) / no_preconditions(...) / formal(...) names must exist (a typo would otherwise drop the option without a word); then a formal is refused on the &Dots parameter, whose formal is ..., a no_default(p) on a parameter that is no choice or has a default (no_default_conflict), the choice parameters are classified (see classify_choice_param), a class in both inherits and not_inherits is refused (crate::r_preconditions::ExplicitChecks::class_conflict), and each parameter’s own precondition decision is checked (check_param_preconditions). The standalone-fn path does the same while parsing; this is the twin for method-level attributes, whose parameter names arrive before the types. The inherent-impl and trait-impl parsers both call it, so they reject an unknown name the same way. inputs has the parameter markers peeled; markers are the ones peeled (empty on a trait impl, whose signature is the trait’s). span is where the errors point: the first such attribute, else the method name.