Closed
Description
Hello!
This trait
pub trait SomeTrait {
const VAL: Option<Self>;
}
triggers
error: a const item should never be interior mutable
|
6 | const VAL: Option<Self>;
| ^^^^^^^^^^^------------^
| |
| consider requiring `std::option::Option<Self>` to be `Copy`
|
which is this lint: https://rust-lang.github.io/rust-clippy/master/index.html#declare_interior_mutable_const
Apparently the corresponding test is this? https://github.com/rust-lang/rust-clippy/blob/master/tests/ui/non_copy_const.rs (not sure!)
Thing is, it doesnt test Option<T>
and additionally: is interior mutability for const Options even such a big deal?
I'm simply trying to figure out if I'm implementing a foot-gun right now if I allow
this. I don't intent to ever manipulate this const and will only use it for PartialEq
and Eq
purposes.
EDIT: @frozolotl on Discord suggested removing Option
from the trait and it should indeed still trigger. And it does. Note: The suggestion to require Copy is not possible in my case.