When I try to use this crate on a struct with atomics, clippy complains about the following:
warning: a `const` item should never be interior mutable
--> src/main.rs:14:5
|
14 | / const DEFAULT: Self = Self {
15 | | atomic: <AtomicUsize as ::const_default::ConstDefault>::DEFAULT,
16 | | };
| |______^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#declare_interior_mutable_const
= note: `#[warn(clippy::declare_interior_mutable_const)]` on by default
This is the code I used:
use std::sync::atomic::AtomicUsize;
static T: Test = <Test as const_default::ConstDefault>::DEFAULT;
#[derive(Debug)]
struct Test {
atomic: AtomicUsize,
}
impl ::const_default::ConstDefault for Test
where
AtomicUsize: ::const_default::ConstDefault,
{
const DEFAULT: Self = Self {
atomic: <AtomicUsize as ::const_default::ConstDefault>::DEFAULT,
};
}
fn main() {
dbg!(&T);
}
I think the crate should add a #[allow(clippy::declare_interior_mutable_const)] above const DEFAULT: Self = Self {, so that it stops complaining
I can open a PR if you are interested
When I try to use this crate on a struct with atomics, clippy complains about the following:
This is the code I used:
I think the crate should add a
#[allow(clippy::declare_interior_mutable_const)]aboveconst DEFAULT: Self = Self {, so that it stops complainingI can open a PR if you are interested