DioxusLabs/dioxus · error
Catch all segments are not allowed in nests
Error message
Catch all segments are not allowed in nests
What it means
When #[derive(Routable)] builds its route tree, it walks each nest's path segments: static segments extend the tree, dynamic segments stop static processing, and a CatchAll segment inside a nest path immediately panics via unimplemented!("Catch all segments are not allowed in nests"). Catch-all segments like :..rest are only valid on routes, never inside a #[nest("...")] prefix.
Source
Thrown at packages/router-macro/src/route_tree.rs:175
},
index,
};
// If it doesn't, add the segment to the current route
let static_segment = self.entries.insert(static_segment);
let current_children = current_route
.map(|id| self.children_mut(id))
.unwrap_or_else(|| &mut segments);
current_children.push(static_segment);
// Update the current route
current_route = Some(static_segment);
}
// If there is a dynamic segment, stop adding static segments
RouteSegment::Dynamic(..) => break,
RouteSegment::CatchAll(..) => {
unimplemented!("Catch all segments are not allowed in nests")
}
}
}
// Add the nest to the current route
let nest = RouteTreeSegmentData::Nest {
nest,
children: Vec::new(),
};
let nest = self.entries.insert(nest);
let segments = match current_route.and_then(|id| self.get_mut(id)) {
Some(RouteTreeSegmentData::Static { children, .. }) => children,
Some(RouteTreeSegmentData::Nest { children, .. }) => children,
Some(r) => {
unreachable!("{current_route:?}\n{r:?} is not a static or nest segment",)
}
None => &mut segments,View on GitHub (pinned to 393d190a80)
Solutions
- Keep the nest path static and put the catch-all on a route inside it: #[nest("/docs")] plus #[route("/:..rest")] DocsRest { rest: Vec<String> }
- Replace the catch-all in the nest prefix with a dynamic segment and enumerate the remaining matching in child routes
- If the nest must capture everything, drop the nest and use a single catch-all route with a layout instead
Example fix
// before: catch-all inside a nest path -> compile-time panic
#[nest("/docs/:..rest")]
// after: static nest, catch-all on the route
#[nest("/docs")]
#[route("/:..rest")]
DocsRest { rest: Vec<String> }, Defensive patterns
Strategy: validation
Validate before calling
// Run in a unit test to catch illegal nest paths before the macro panics
#[test]
fn nest_paths_have_no_catch_all() {
let nest_paths = ["/docs", "/blog"]; // keep in sync with your Route enum
for p in nest_paths {
assert!(!p.contains(":.."), "catch-all segment in nest path {p:?} is not allowed");
}
} Prevention
- Only use static or single :dynamic segments in #[nest("...")] paths; catch-alls belong on #[route] variants
- Keep a naming review when refactoring flat catch-all routes into nests
- Compile the crate after every route-enum edit — this failure is always compile-time
When it happens
Trigger: Writing a Route enum whose #[nest("...")] attribute path contains a catch-all segment, e.g. #[nest("/docs/:..rest")]. The proc macro panics while constructing the parse tree, so the crate fails to compile.
Common situations: Trying to make a nest 'own' all remaining URL space (e.g. a wiki nest that should capture arbitrary subpaths); refactoring a flat catch-all route into a nest and moving the :..rest segment into the nest attribute by mistake.
Related errors
- Cannot have multiple query parameters when one is a catch-al
- Use `api_route` instead of `route` to use OpenAPI options
- path parameter `{}` not found in function arguments
- query parameter `{}` not found in function arguments
- HTTP method specified both in macro and in attribute
AI-assisted analysis of DioxusLabs/dioxus@393d190a80 (2026-08-16).
Data as JSON: /api/errors/b324a65ca9a837ae.
Report an issue: GitHub.