Skip to content

return in regex_switch triggers non relevant warning from rustc #40

@Canop

Description

@Canop

This (shortened) code does what's expected:

        regex_switch!(s,
            r"^export:(?<name>.+)$" => Self::Export(name.to_string()),
            r"^(?:internal:)?toggle-backtrace\(2\)$" => Self::ToggleBacktrace("2"),
            r"^(?:internal:)?toggle-backtrace\(full\)$" => Self::ToggleBacktrace("full"),
            r"^(?:internal:)?toggle-backtrace\((?<level>)\)$" => {
                return Err(ParseActionError::InvalidBacktraceLevel(level.to_string()));
            }
            r"^(?:internal:)?toggle-summary$" => Self::ToggleSummary,
            r"^focus[_-]file\((?<file>.*)\)$" => Self::FocusFile(FocusFileCommand::new(file)),
        ).ok_or(ParseActionError::UnknownAction(s.to_string()))

But it triggers an "unreachable_code" warning:

Image

I'm not sure yet of the best way to prevent this false positive.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions