You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I had an enum that derived Snafu, and I added a variant to it:
use snafu::Snafu;use std::{io, path::PathBuf, sync::Arc};#[derive(Debug,Snafu,Clone)]enumMyError{UnableToRead{#[snafu(source(from(io::Error,Arc::new)))]source:Arc<io::Error>,path:PathBuf,},}
I did not use this variant anywhere.
What I expected
Usually when I have an enum variant that's unused, Rust gives a dead_code warning about it:
use std::{io, path::PathBuf, sync::Arc};enumMyError{UsingThisOne,UnableToRead{source:Arc<io::Error>,path:PathBuf,},}fnmain(){let _f = MyError::UsingThisOne;}
produces:
warning: variant is never constructed: `UnableToRead`
--> src/main.rs:7:5
|
7 | / UnableToRead {
8 | | source: Arc<io::Error>,
9 | | path: PathBuf,
10 | | },
| |_____^
|
= note: `#[warn(dead_code)]` on by default
It'd be nice to have this warning for Snafu enum variants as well.
The text was updated successfully, but these errors were encountered:
Hmm, this does seem valuable, but might be tricky and maybe outside of SNAFU's ability.
I think the problem is that we generate structs for each variant, and each struct has methods and/or trait implementations which generate that variant, which means that the variant isn't unused.
I think that the struct itself isn't marked as unused because nothing generated by a procedural macro is marked as unused. I don't know of a way to indicate otherwise.
warning: variant `UnableToRead` is never constructed
--> src/main.rs:6:5
|
5 | enum MyError {
| ------- variant in this enum
6 | UnableToRead {
| ^^^^^^^^^^^^
|
= note: `MyError` has derived impls for the traits `Clone` and `Debug`, but these are intentionally ignored during dead code analysis
= note: `#[warn(dead_code)]` on by default
What happened
I had an enum that derived
Snafu
, and I added a variant to it:I did not use this variant anywhere.
What I expected
Usually when I have an enum variant that's unused, Rust gives a
dead_code
warning about it:produces:
It'd be nice to have this warning for Snafu enum variants as well.
The text was updated successfully, but these errors were encountered: