rwf2/Rocket · error · rocket_codegen::param::Error
Ignored
Ignored
Error message
parameter must be named
What it means
Compile-time error from Rocket's codegen: the wildcard parameter <_> was used in a segment kind that does not allow ignored parameters. Only Path-kind segments (P::KIND == Kind::Path) accept the ignored wildcard; using <_> or <_..> in a query segment (or any non-Path Part) is rejected with ErrorKind::Ignored ('parameter must be named'). Query parameters must always be named because the name is the query key.
Source
Thrown at core/codegen/src/attribute/param/parse.rs:68
// 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)];
}
let span = subspan(name, segment, source_span);
if name.is_empty() {
return Err(Error::new(name, source_span, ErrorKind::Empty));
} else if !is_valid_ident(name) {
return Err(Error::new(name, span, ErrorKind::BadIdent));
}
let dynamic = Dynamic { name: Name::new(name, span), trailing, index: 0 };
if dynamic.is_wild() && P::KIND != Kind::Path {
return Err(Error::new(name, span, ErrorKind::Ignored));
} else if dynamic.is_wild() {
return Ok(Parameter::Ignored(dynamic));
} else {
return Ok(Parameter::Dynamic(dynamic));
}
} else if segment.is_empty() {
return Err(Error::new(segment, source_span, ErrorKind::Empty));
} else if segment.starts_with('<') && lint.enabled(source_span) {
let candidate = candidate_from_malformed(segment);
source_span.warning("`segment` starts with `<` but does not end with `>`")
.help(format!("perhaps you meant the dynamic parameter `<{}>`?", candidate))
.note(lint.how_to_suppress())
.emit_as_item_tokens();
} else if (segment.contains('>') || segment.contains('<')) && lint.enabled(source_span) {
source_span.warning("`segment` contains `<` or `>` but is not a dynamic parameter")
.emit_as_item_tokens();
}
View on GitHub (pinned to 3a54d079ae)
Solutions
- Name the query parameter and bind it in the handler: #[get("/hello?<_rest..>")] → #[get("/hello?<id>")]
- To ignore extra query params, simply omit them — unbound query keys are ignored by default; bind only the keys you need
- Remember <_> is only legal in path position: /hello/<_> is fine, /hello?<_> is not
Example fix
// before
#[get("/search?<_..>")]
fn search() { }
// after
#[get("/search?<q>")]
fn search(q: &str) { } Defensive patterns
Strategy: validation
Prevention
- Remember <_> is legal only in path segments, never in ?query segments
- Unbound query keys are ignored by default — bind only the ones you need, by name
- Use <rest..> style named trailing params in queries
When it happens
Trigger: #[get("/hello?<_..>")] — trying to ignore trailing query params; #[get("/hello?<_>")] — ignoring a single query param; the same inside FromMeta contexts that parse with fmt::Query (e.g. cookie/flash attribute values).
Common situations: Wanting to accept-and-ignore extra query parameters while only forwarding some; copying the path wildcard style <_> (valid in paths, e.g. /hello/<_>) into the ?query part of the route.
Related errors
AI-assisted analysis of rwf2/Rocket@3a54d079ae (2026-08-16).
Data as JSON: /api/errors/d318d4b9cbd456b1.
Report an issue: GitHub.