I just found the following code:
drop(env_logger::try_init());
Basically someone got a warning on an unused must_use type (in this case a Result), and thus "used" it … by dropping it. Tada, the warning's gone :tada:.
clippy::correctnessNone.
drop(crate::try_do_stuff());
Could be written as:
crate::try_do_stuff().unwrap();
If the drop was intentional, it should be:
drop(crate::try_do_stuff().unwrap());
This is related to the following lints:
clippy::correctness::drop_copyclippy::correctness::drop_refI think these two shall take precedence over the proposed lint, because they are more important.
I think we should only implement the proposed new lint on non-Copy owned types, and call it drop_must_use, in clippy::style as I don't think this is "incorrect".
Sounds good. However, I'm think dropping a Result and thus not doing error handling is "incorrect" to me. I can't think of any use case where dropping a Result instead of handling it would be desired semantics. Note that I come from a pure Result perspective and don't know of similar situations with other must_use types.
I don't think we should suggest unwraping the result as that would change semantics (a dropped error is not unwrapped).
Wouldn't a more idiomatic way to write that be:
let _ = crate::try_do_stuff();
This would apply to non-Result types too. Note that the behavior would be the same, as binding to _ destroys the assigned value at the end of the statement.
Most helpful comment
This is related to the following lints:
clippy::correctness::drop_copyclippy::correctness::drop_refI think these two shall take precedence over the proposed lint, because they are more important.
I think we should only implement the proposed new lint on non-Copy owned types, and call it
drop_must_use, inclippy::styleas I don't think this is "incorrect".