Proc macro not showing unreachable match arm

I have a proc macro that generates a match expression along with match arms. Unfortunately for me, if I order the match arms where matches should then become unreachable, they aren't flagged as unreachable by the compiler. This puzzles me. For example, take this example from my DSL:

#[impl_fsm]
impl Fsm<State, Input, Output, ()> for MyFsm {
    state!(B / entry);
    state!(B / exit);

    transition!(A => I0 => O0 => B);
    transition!(B => I1 => O1 => A);
    transition!(B => I2 => O2);
    transition!(B => I3);

    transition!(_ => I1 => O1 => A);
    transition!(_ => I2 => O2);
    transition!(_ => I3);
}

That's valid and all is well. However, if I move one of my "any" transitions up to the top i.e.:

#[impl_fsm]
impl Fsm<State, Input, Output, ()> for MyFsm {
    state!(B / entry);
    state!(B / exit);

    transition!(_ => I1 => O1 => A);

    transition!(A => I0 => O0 => B);
    transition!(B => I1 => O1 => A);
    transition!(B => I2 => O2);
    transition!(B => I3);

    transition!(_ => I2 => O2);
    transition!(_ => I3);
}

...then the compiler appears happy.

I've used cargo expand on my test and then pasted code into the Rust playground. The compiler picks up the unreachable match arms. Thus, it must be something to do with how I'm generating the output.

In case it helps, that transition! macro doesn't actually exist... it is something I use to contain my own DSL only.

Any thoughts? Here's my project, lined up at the specific test case: edfsm/exercise_fsm.rs at main · titanclass/edfsm · GitHub Thanks for any help.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.