-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Closed
Labels
C-bugCategory: Clippy is not doing the correct thingCategory: Clippy is not doing the correct thingE-hardCall for participation: This a hard problem and requires more experience or effort to work onCall for participation: This a hard problem and requires more experience or effort to work onI-false-positiveIssue: The lint was triggered on code it shouldn't haveIssue: The lint was triggered on code it shouldn't have
Description
Consider this (crappy code)
macro_rules! foo {
($($i:ident: $ty:ty, $def:expr);+ $(;)*) => {
pub fn bar(key: &str) -> bool {
match key {
$(
stringify!($i) => {
let res = <$ty>::default() == $def;
let _i: $ty = $def;
return res;
}
)+
_ => false,
}
}
};
}
foo! {
max_width: usize, 100;
required_version: String, env!("HOME").to_string();
}
Clippy outputs this warnings:
warning: this creates an owned instance just for comparison
--> src/lib.rs:20:31
|
20 | required_version: String, env!("HOME").to_string();
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `env!("HOME")`
|
= note: `#[warn(clippy::cmp_owned)]` on by default
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#cmp_owned
Which is wrong.
cargo clippy --version
: clippy 0.0.212 (69f99e7 2019-12-14)
Metadata
Metadata
Assignees
Labels
C-bugCategory: Clippy is not doing the correct thingCategory: Clippy is not doing the correct thingE-hardCall for participation: This a hard problem and requires more experience or effort to work onCall for participation: This a hard problem and requires more experience or effort to work onI-false-positiveIssue: The lint was triggered on code it shouldn't haveIssue: The lint was triggered on code it shouldn't have