Closed
Description
Hi,
I have a trace macro which normally expands to nothing, but can be turned on by a Cargo feature. I get match_same_arms
warning on a case like this:
macro_rules! trace {
($e:expr) => ()
}
pub enum Foo { A, B, C }
use Foo::*;
pub fn test(x: Foo) {
match x {
A => { println!("something"); },
B => { trace!("Got B"); },
_ => {},
}
}
which gives the following warning:
warning: this `match` has identical arm bodies, #[warn(match_same_arms)] on by default
--> src/lib.rs:15:14
|
15 | _ => {},
| ^^
|
note: same as this
--> src/lib.rs:14:14
|
14 | B => { trace!("Got B"); },
| ^^^^^^^^^^^^^^^^^^^^
note: `B` has the same arm body as the `_` wildcard, consider removing it`
--> src/lib.rs:14:14
|
14 | B => { trace!("Got B"); },
| ^^^^^^^^^^^^^^^^^^^^
= help: for further information visit https://github.com/Manishearth/rust-clippy/wiki#match_same_arms
In some sense they expand to the same, but they're not the same to me the programmer; when I turn on a feature the tracing becomes more useful.
Playground link: https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=929ad50b7c6d82e2df6bf3a8cbd7a944
Metadata
Metadata
Assignees
Labels
Category: Interesting projects, that usually are more involved design/code wise.Category: Clippy is not doing the correct thingCall for participation: This a hard problem and requires more experience or effort to work onIssue: The lint was triggered on code it shouldn't haveType: Probably requires verifiying types