rwf2/Rocket · error · rocket_codegen::param::Error
Static
Static
Error message
unexpected static parameter
What it means
This is a compile-time codegen error from Rocket's route/attribute parameter parser. Dynamic::parse expects a dynamic parameter of the form <name> (optionally trailing, <name..>); when Parameter::parse classifies the segment as Parameter::Static (no surrounding angle brackets), Dynamic::parse rejects it with ErrorKind::Static ('unexpected static parameter'). It appears in attribute positions that require a dynamic parameter binding, such as data = "<param>" on a route or other FromMeta contexts that parse a Dynamic.
Source
Thrown at core/codegen/src/attribute/param/parse.rs:38
#[derive(Debug, PartialEq, Eq, Copy, Clone)]
pub enum ErrorKind {
Empty,
BadIdent,
Ignored,
EarlyTrailing,
NoTrailing,
Static,
}
impl Dynamic {
pub fn parse<P: Part>(
segment: &str,
span: Span,
) -> Result<Self, Error<'_>> {
match Parameter::parse::<P>(segment, span)? {
Parameter::Dynamic(d) | Parameter::Ignored(d) => Ok(d),
Parameter::Guard(g) => Ok(g.source),
Parameter::Static(_) => Err(Error::new(segment, span, ErrorKind::Static)),
}
}
}
impl Parameter {
pub fn parse<P: Part>(
segment: &str,
source_span: Span,
) -> Result<Self, Error<'_>> {
let mut trailing = false;
// Check if this is a dynamic param. If so, check its well-formedness.
let lint = Lint::SegmentChars;
if segment.starts_with('<') && segment.ends_with('>') {
let mut name = &segment[1..(segment.len() - 1)];
if name.ends_with("..") {
trailing = true;
name = &name[..(name.len() - 2)];View on GitHub (pinned to 3a54d079ae)
Solutions
- Wrap the parameter name in angle brackets: data = "<payload>"
- Check the exact attribute position the error span points at — only route paths allow static segments; parameter bindings like data = require <name>
- Re-run cargo check to confirm the span now parses
Example fix
// before
#[post("/upload", data = "payload")]
fn upload(payload: TempFile<'_>) { }
// after
#[post("/upload", data = "<payload>")]
fn upload(payload: TempFile<'_>) { } Defensive patterns
Strategy: validation
Prevention
- Treat data = "<name>" as the only valid form — angle brackets required
- Match the name inside <...> exactly to the handler argument name
- Run cargo check early after editing route macros to catch codegen errors before runtime
When it happens
Trigger: Writing a static string where a dynamic parameter is required, e.g. #[post("/upload", data = "payload")] instead of data = "<payload>", or any attribute value parsed via the FromMeta impl for Dynamic that lacks <...> delimiters.
Common situations: Forgetting the angle brackets on the data parameter of a route macro; copying a query string field name style (id=5) into a dynamic-parameter slot; muscle memory from other frameworks where the parameter name is bare.
Related errors
AI-assisted analysis of rwf2/Rocket@3a54d079ae (2026-08-16).
Data as JSON: /api/errors/c272b77dcec6156f.
Report an issue: GitHub.