rwf2/Rocket · error · syn::Error

invalid lint `{name}` (known lints: {})

Error message

invalid lint `{name}` (known lints: {})

What it means

Compile-time syn parse error from Rocket's lint-suppression attribute parser: #[suppress(name)] was given a name that does not match any declared lint. The valid names are fixed by declare_lints! in core/codegen/src/attribute/suppress/lint.rs: unknown_format, dubious_payload, segment_chars, arbitrary_main, sync_spawn (matching is case-insensitive). The error message lists all known lints.

Source

Thrown at core/codegen/src/attribute/suppress/lint.rs:112

        })
    }

    pub fn enabled(self, ctxt: Span) -> bool {
        !self.is_suppressed(ctxt)
    }

    pub fn how_to_suppress(self) -> String {
        format!("apply `#[suppress({})]` before the item to suppress this lint", self.as_str())
    }
}

impl syn::parse::Parse for Lint {
    fn parse(input: syn::parse::ParseStream<'_>) -> syn::Result<Self> {
        let ident: syn::Ident = input.parse()?;
        let name = ident.to_string();
        Lint::from_str(&name).ok_or_else(|| {
            let msg = format!("invalid lint `{name}` (known lints: {})", Lint::lints());
            syn::Error::new(ident.span(), msg)
        })
    }
}

View on GitHub (pinned to 3a54d079ae)

Solutions

  1. Use one of the listed names exactly: unknown_format, dubious_payload, segment_chars, arbitrary_main, sync_spawn
  2. For compiler lints (unused, dead_code), use #[allow(...)] instead — #[suppress] is only for Rocket's own codegen lints
  3. Check spelling separators: names use underscores, e.g. segment_chars not segmentchars

Example fix

// before
#[suppress(segmentchars)]
#[get("/a/<id>")]
fn a(id: &str) { }

// after
#[suppress(segment_chars)]
#[get("/a/<id>")]
fn a(id: &str) { }
Defensive patterns

Strategy: validation

Prevention

When it happens

Trigger: Writing #[suppress(segmentchars)] (missing underscore), #[suppress(unused)] (a rustc lint, not a Rocket lint), or any typo'd name inside #[suppress(...)] on an item. It fires during syn parsing of the attribute, before expansion.

Common situations: Confusing Rocket's #[suppress] with #[allow] for compiler lints; upgrading Rocket versions where lint names changed; suppressing a lint remembered from an older release.

Related errors


AI-assisted analysis of rwf2/Rocket@3a54d079ae (2026-08-16). Data as JSON: /api/errors/639b3adfb1833862. Report an issue: GitHub.