rwf2/Rocket · error · rocket_codegen::param::Error

Empty

Empty

Error message

parameters cannot be empty

What it means

Compile-time error from Rocket's route parameter parser: a dynamic segment <...> was supplied but the name inside the brackets (after stripping a trailing ..) is empty. Both <> and <..> (trailing wildcard with no name) hit the ErrorKind::Empty branch at the top of the dynamic-param parsing in Parameter::parse. Rocket requires every dynamic parameter, including trailing ones, to have a valid name.

Source

Thrown at core/codegen/src/attribute/param/parse.rs:61

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)];
            }

            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))

View on GitHub (pinned to 3a54d079ae)

Solutions

  1. Give the parameter a name: #[get("/<id..>")] instead of #[get("/<..>")]
  2. For an intentionally ignored catch-all path segment use the named wildcard underscore only where allowed: <rest..> with a matching &rest Path argument, or <_..> only in path position
  3. For a plain static route, remove the angle brackets entirely

Example fix

// before
#[get("/<..>")]
fn all() { }

// after
#[get("/<rest..>")]
fn all(rest: Path<String>) { }
Defensive patterns

Strategy: validation

Prevention

When it happens

Trigger: #[get("/<>")] — empty dynamic segment; #[get("/<..>")] — unnamed trailing parameter; the same patterns inside query segments like /path?<>.

Common situations: Trying to express 'match anything here' with <> or copying a wildcard style from other frameworks; refactoring a path and accidentally deleting the parameter name but leaving the brackets.

Related errors


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