rust-lang/cargo · error

`lints. . ` is not valid lint name; try `lints. .

Error message

`lints.{tool}.{name}` is not valid lint name; try `lints.{prefix}.{suffix}`

What it means

Thrown during [lints] validation when a lint name contains '::' and the segment before '::' equals the tool name. For example [lints.rust] with a key 'rust::dead_code' repeats the tool namespace. The correct form drops the redundant prefix: lints.rust.dead_code. The message suggests lints.{prefix}.{suffix} but here prefix equals tool, so the fix is to use just lints.{tool}.{suffix}.

Solutions

  1. Remove the redundant tool prefix from the lint key: use 'dead_code' not 'rust::dead_code' under [lints.rust].
  2. Consult the lint's documentation for its bare name within the tool's namespace.

Example fix

# before
[lints.rust]
"rust::dead_code" = "warn"

# after
[lints.rust]
dead_code = "warn"
Defensive patterns

Strategy: validation

Validate before calling

fn lint_name_no_redundant_tool_prefix(tool: &str, name: &str) -> Result<(), String> {
    if let Some((prefix, _)) = name.split_once("::") {
        if prefix == tool {
            return Err(format!("remove redundant `{tool}::` from lint `{name}`"));
        }
    }
    Ok(())
}

Type guard

fn is_bare_lint_name(name: &str) -> bool { !name.contains("::") }

Prevention

When it happens

Trigger: Writing [lints.rust] section with a key like 'rust::dead_code'. The split_once("::") yields (prefix='rust', suffix='dead_code'), and the branch tool == prefix fires.

Common situations: A developer copies a lint name from a compiler message that includes the tool prefix (e.g. 'rust dead_code') and writes it verbatim. Confusion about whether the [lints] table key should include the tool namespace.

Related errors


AI-assisted analysis of rust-lang/cargo@98a09e7e7d (2026-08-11). Data as JSON: /api/errors/1a153f1230c7cb09. Report an issue: GitHub.

Appendix: source

Thrown at src/workspace/parser/mod.rs:2737

        for (name, config) in lints {
            let normalized = name.replace('-', "_");
            if name.contains('-') {
                warnings.push(format!(
                    "`lints.{tool}.{name}` is deprecated in favor of \
                     `lints.{tool}.{normalized}` and will not work in a \
                     future edition"
                ));
            }
            if let Some(existing) = seen_normalized.get(&normalized) {
                warnings.push(format!(
                    "duplicate lint `{existing}` in `[lints.{tool}]`, \
                     conflicts with `{name}` and will not work in a future edition"
                ));
            }
            seen_normalized.insert(normalized.clone(), name.to_string());
            if let Some((prefix, suffix)) = name.split_once("::") {
                if tool == prefix {
                    anyhow::bail!(
                        "`lints.{tool}.{name}` is not valid lint name; try `lints.{prefix}.{suffix}`"
                    )
                } else if tool == "rust" && supported.contains(&prefix) {
                    anyhow::bail!(
                        "`lints.{tool}.{name}` is not valid lint name; try `lints.{prefix}.{suffix}`"
                    )
                } else {
                    anyhow::bail!("`lints.{tool}.{name}` is not a valid lint name")
                }
            } else if let Some(config) = config.config() {
                for config_name in config.keys() {
                    // manually report unused manifest key warning since we collect all the "extra"
                    // keys and values inside the config table
                    let expected = EXPECTED_LINT_CONFIG.contains(&(tool, name, config_name));
                    if !expected {
                        let message =
                            format!("unused manifest key: `lints.{tool}.{name}.{config_name}`");
                        warnings.push(message);

View on GitHub (pinned to 98a09e7e7d)