Skip to content

Commit

Permalink
Actually think these are unreachable
Browse files Browse the repository at this point in the history
  • Loading branch information
davidpdrsn committed Jul 16, 2023
1 parent 1b7b872 commit 81c8dca
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions axum/src/routing/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,9 @@ where
where
R: Into<Router<S>>,
{
const PANIC_MSG: &str =
"Failed to merge fallbacks. This is a bug in axum. Please file an issue";

let Router {
path_router,
fallback_router: mut other_fallback,
Expand All @@ -199,17 +202,17 @@ where
// both have the default fallback
// use the one from other
(true, true) => {
panic_on_err!(self.fallback_router.merge(other_fallback));
self.fallback_router.merge(other_fallback).expect(PANIC_MSG);
}
// self has default fallback, other has a custom fallback
(true, false) => {
panic_on_err!(self.fallback_router.merge(other_fallback));
self.fallback_router.merge(other_fallback).expect(PANIC_MSG);
self.default_fallback = false;
}
// self has a custom fallback, other has a default
(false, true) => {
let fallback_router = std::mem::take(&mut self.fallback_router);
panic_on_err!(other_fallback.merge(fallback_router));
other_fallback.merge(fallback_router).expect(PANIC_MSG);
self.fallback_router = other_fallback;
}
// both have a custom fallback, not allowed
Expand Down

0 comments on commit 81c8dca

Please sign in to comment.