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
NB: Not sure if fixing this issue is the responsibility of derivative or clippy, but there may be a proactive solution that derivative can implement that can future-proof against these kinds of bugs.
Describe the bug
On nightly, if we implement Clone using derivative::Derivative on the following enum
pubenumEnum<T>{/// First ChoiceFirst,/// Second ChoiceSecond,/// Parameter Marker#[doc(hidden)]
__(Infallible,PhantomData<T>),}
clippy overreacts with
warning: unreachable expression
|
| #[derive(derivative::Derivative)]
| ^^^^^^^^^^^^^^^^^^^^^^
| |
| unreachable expression
| any code following this expression is unreachable
|
= note: `#[warn(unreachable_code)]` on by default
note: this expression has type `Infallible`, which is uninhabited
|
| #[derive(derivative::Derivative)]
| ^^^^^^^^^^^^^^^^^^^^^^
= note: this warning originates in the derive macro `derivative::Derivative` (in Nightly builds, run with -Z macro-backtrace for more info)
Implementing Clone using the standard library derive macro doesn't give the error but it has the undesirable property that it automatically adds the T: Clone constraint where derivative does not.
To Reproduce
Here's a rust playground example with the standard library derive and derivative::Derivative.
Expected behavior
I expected no warning since it did not give a warning in the past (and the warning is not helpful either).
Errors
N/A
Version (please complete the following information):
Additional context
You can also just try to silence the warning from clippy by adding #[allow(unreachable_code)] but no matter where you put it on the enum, above the variant, above the pub enum Enum<T> line, or above the #[derive(derivative::Derivative)] line, clippy still complains. You can only silence the warning by putting a global #![allow(unreachable_code)] but this is not safe.
The text was updated successfully, but these errors were encountered:
NB: Not sure if fixing this issue is the responsibility of
derivative
orclippy
, but there may be a proactive solution thatderivative
can implement that can future-proof against these kinds of bugs.Describe the bug
On nightly, if we implement
Clone
usingderivative::Derivative
on the followingenum
clippy
overreacts withImplementing
Clone
using the standard libraryderive
macro doesn't give the error but it has the undesirable property that it automatically adds theT: Clone
constraint wherederivative
does not.To Reproduce
Here's a rust playground example with the standard library
derive
andderivative::Derivative
.Expected behavior
I expected no warning since it did not give a warning in the past (and the warning is not helpful either).
Errors
N/A
Version (please complete the following information):
Additional context
You can also just try to silence the warning from
clippy
by adding#[allow(unreachable_code)]
but no matter where you put it on theenum
, above the variant, above thepub enum Enum<T>
line, or above the#[derive(derivative::Derivative)]
line,clippy
still complains. You can only silence the warning by putting a global#![allow(unreachable_code)]
but this is not safe.The text was updated successfully, but these errors were encountered: