Macro create_lint_rule_config

Source
macro_rules! create_lint_rule_config {
    ($(
        $(#[doc = $doc:literal])+
        $(#[default_text = $default_text:expr])?
        $name:ident: $type:ty = $default:expr,
    )*) => { ... };
}
Expand description

Creates the LintRuleConfiguration struct that defines all available lint rules.

Every lint rule is defined using the same structure, e.g.:

/// This is a test option
test_option: String = "This is a default",
  • /// This is a test option: The documentation that is associated with the option.
  • test_option: The name of the option.
  • : String: The data type of the option value.
  • = "This is a default": The default value for the option. Anything that implements Into for the target data type is accepted.

§Parameters

The macro accepts additional parameters. These have the form of #[param_name = param_value] and are positioned above the option declaration, for example:

This list of parameters is currently supported:

  • #[default_text = "some default"]: Use this, if your default value depends on runtime data. This is used to set the human readable text in documentation contexts. For example set #[default_text = "current architecture"] for lints that default to the system’s architecture that is detected during linting runtime.

    Example:

    /// This is a test option
    #[default_text = "current architecture"]
    architecture: Option<Architecture> = None,