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

NoTrailing

NoTrailing

Error message

parameter cannot be trailing

What it means

Compile-time error from the FromMeta impl for Dynamic (parse.rs:184): the attribute value parsed as a Path-kind dynamic parameter has trailing = true (a <name..> form), but this attribute context does not accept trailing parameters, so it is rejected with ErrorKind::NoTrailing ('parameter cannot be trailing'). Trailing syntax is only meaningful inside route origin strings, not in single-parameter attribute values like data =.

Source

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

            ErrorKind::Static => {
                let candidate = candidate_from_malformed(error.segment);
                error.span.error(error.kind.to_string())
                    .help(format!("parameter must be dynamic: `<{}>`", candidate))
            }
        }
    }
}

impl devise::FromMeta for Dynamic {
    fn from_meta(meta: &devise::MetaItem) -> devise::Result<Self> {
        let string = StringLit::from_meta(meta)?;
        let span = string.subspan(1..string.len() + 1);
        let param = Dynamic::parse::<Path>(&string, span)?;

        if param.is_wild() {
            return Err(Error::new(&string, span, ErrorKind::Ignored).into());
        } else if param.trailing {
            return Err(Error::new(&string, span, ErrorKind::NoTrailing).into());
        } else {
            Ok(param)
        }
    }
}

fn subspan(needle: &str, haystack: &str, span: Span) -> Span {
    let index = needle.as_ptr() as usize - haystack.as_ptr() as usize;
    StringLit::new(haystack, span).subspan(index..index + needle.len())
}

fn trailspan(needle: &str, haystack: &str, span: Span) -> Span {
    let index = needle.as_ptr() as usize - haystack.as_ptr() as usize;
    let lit = StringLit::new(haystack, span);
    if needle.as_ptr() as usize > haystack.as_ptr() as usize {
        lit.subspan((index - 1)..)
    } else {
        lit.subspan(index..)

View on GitHub (pinned to 3a54d079ae)

Solutions

  1. Remove the trailing dots: data = "<file..>" → data = "<file>"
  2. Keep <name..> syntax only inside the route path string itself

Example fix

// before
#[post("/upload", data = "<file..>")]
fn upload(file: TempFile<'_>) { }

// after
#[post("/upload", data = "<file>")]
fn upload(file: TempFile<'_>) { }
Defensive patterns

Strategy: validation

Prevention

When it happens

Trigger: #[post("/upload", data = "<file..>")] — trailing marker on a data binding; any FromMeta-parsed Dynamic value containing the .. suffix.

Common situations: Copying a catch-all path segment (<path..>) into the data = slot; misunderstanding that data = binds a single stream, not multiple segments.

Related errors


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