-
Notifications
You must be signed in to change notification settings - Fork 69
Open
Description
Using an empty enum as source produces an unreachable_code warning. Which is certainly true, but should it do that? Sometimes you want to return a Result for forward compatibility or whatever.
use snafu::ResultExt as _;
#[derive(Debug, snafu::Snafu)]
enum Outer {
Inner { source: Inner },
}
#[derive(Debug, snafu::Snafu)]
enum Inner {}
fn infallible() -> Result<(), Inner> {
Ok(())
}
fn main() -> Result<(), Outer> {
infallible().context(InnerSnafu)
}warning: unreachable expression
--> src/main.rs:3:17
|
3 | #[derive(Debug, snafu::Snafu)]
| ^^^^^^^^^^^^
| |
| unreachable expression
| any code following this expression is unreachable
|
note: this expression has type `Inner`, which is uninhabited
--> src/main.rs:3:17
|
3 | #[derive(Debug, snafu::Snafu)]
| ^^^^^^^^^^^^
= note: `#[warn(unreachable_code)]` on by default
= note: this warning originates in the derive macro `snafu::Snafu` (in Nightly builds, run with -Z macro-backtrace for more info)
warning: `snafu-unreachable` (bin "snafu-unreachable") generated 1 warning
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels