DioxusLabs/dioxus · error · syn::Error

Catch-all route segments must be the last segment in a…

Error message

Catch-all route segments must be the last segment in a route. The route segments after the catch-all segment will never be matched.

What it means

`parse_route_segments` errors when a catch-all (`:..name`) segment is followed by more segments. Segments after a catch-all can never match because the catch-all consumes the rest of the path, so such routes are rejected at compile time.

Solutions

  1. Move the catch-all segment (..) to the end of the route; any segments after it can never be matched.
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at packages/router-macro/src/segment.rs:205 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of DioxusLabs/dioxus@24f6a829df (2026-08-23). Data as JSON: /api/errors/2a5f28b10a12c950. Report an issue: GitHub.

Appendix: source

Thrown at packages/router-macro/src/segment.rs:205

            let field = fields.clone().find(|(name, _)| **name == ident);

            let ty = if let Some(field) = field {
                field.1.clone()
            } else {
                return Err(syn::Error::new(
                    route_span,
                    format!("Could not find a field with the name '{}'", ident,),
                ));
            };
            if spread {
                route_segments.push(RouteSegment::CatchAll(
                    Ident::new(&ident, Span::call_site()),
                    ty,
                ));

                if iterator.next().is_some() {
                    return Err(syn::Error::new(
                        route_span,
                        "Catch-all route segments must be the last segment in a route. The route segments after the catch-all segment will never be matched.",
                    ));
                } else {
                    break;
                }
            } else {
                route_segments.push(RouteSegment::Dynamic(
                    Ident::new(&ident, Span::call_site()),
                    ty,
                ));
            }
        } else {
            route_segments.push(RouteSegment::Static(segment.to_string()));
        }
    }

    Ok((route_segments, query, hash))

View on GitHub (pinned to 24f6a829df)