"Unreachable call" warning from derive Routable and `String` dynamic segments

Open Beginner friendly
#6,095 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
76/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
rust

Research direction

The reproducer is in the issue body: a Routable enum with a String dynamic segment. Start by running cargo check on that example, then inspect the Routable derive implementation and its route parsing tests. Done means the example compiles without the unreachable-call warning and relevant tests pass.

Written by the indexing model from the issue text.

Description

bug

Problem

Starting from Rust 1.100.0, I get a warning (unreachable call) when using #[derive(Routable)] if the route takes a String dynamic segment.

Steps To Reproduce

Steps to reproduce the behavior:

  • create a new web project with routes
  • add a route with a String dynamic segment
  • cargo check

This main.rs is enough to expose the problem:

use dioxus::prelude::*;

#[derive(Debug, Clone, Routable, PartialEq)]
#[rustfmt::skip]
enum Route {
    #[route("/:s")]
    Echo { s: String },
}

fn main() {
    dioxus::launch(App);
}

#[component]
fn App() -> Element {
    rsx! {
        Router::<Route> {}
    }
}

#[component]
pub fn Echo(s: String) -> Element {
    rsx! { "You said: {s}" }
}

Expected behavior

I expect it to compile without warnings.

** Screenshot **

❯ cargo check
warning: unreachable call
 --> src/main.rs:3:24
  |
3 | #[derive(Debug, Clone, Routable, PartialEq)]
  |                        ^^^^^^^^
  |                        |
  |                        unreachable call
  |                        any code following this expression is unreachable
  |
  = note: `#[warn(unreachable_code)]` (part of `#[warn(unused)]`) on by default
  = note: this warning originates in the derive macro `Routable` (in Nightly builds, run with -Z macro-backtrace for more info)

Environment:

  • Dioxus version: dioxus 0.7.10 (57d6794)
  • Rust version: 1.100.0
  • OS info: Linux (Ubuntu 26.04)
  • App platform: web

Questionnaire

I don't have time to fix this right now, but maybe later.

Dominant language
Rust
Stars
39.8k
Forks
2k
Avg merge
14h 29m
Merged PRs (30d)
20

Getting set up

Open in Codespaces

Starts the project's dev container in your browser, under your own GitHub account.

  • No Dockerfile or Docker Compose file
  • No pull request template
  • No contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from DioxusLabs/dioxus

All issues in DioxusLabs/dioxus

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.