illicitonion / num_enum

Apache License 2.0
264 stars 34 forks source link

Constant should have UPPER_SNAKE_CASE name, #128

Closed l-7-l closed 1 year ago

l-7-l commented 1 year ago
    #[derive(
        Debug, Clone, Copy, Serialize_repr, Deserialize_repr, IntoPrimitive, FromPrimitive,
    )]
    #[repr(i16)]
    pub enum MediaKind {
        #[default]
        Image = 0, // warning:  Constant `Image__num_enum_0__` should have UPPER_SNAKE_CASE name, e.g. `IMAGE_NUM_ENUM_0`rust-analyzer[non_upper_case_globals](https://doc.rust-lang.org/rustc/?search%3Dnon_upper_case_globals)
        Video = 1, // warning:  Constant `Video__num_enum_0__` should have UPPER_SNAKE_CASE name, e.g. `VIDEO_NUM_ENUM_0`rust-analyzer[non_upper_case_globals](https://doc.rust-lang.org/rustc/?search%3Dnon_upper_case_globals)
        Audio = 2, // warning:  Constant `Audio__num_enum_0__` should have UPPER_SNAKE_CASE name, e.g. `AUDIO_NUM_ENUM_0`rust-analyzer[non_upper_case_globals](https://doc.rust-lang.org/rustc/?search%3Dnon_upper_case_globals)
    }

    impl MediaKind {
        pub fn as_i16(&self) -> i16 {
            (*self).into()
        }
    }

num_enum = "0.7.0"

rustc -V rustc 1.73.0-nightly (d06ca0ffa 2023-08-18)

cargo clippy -V clippy 0.1.73 (d06ca0f 2023-08-18)

tech6hutch commented 1 year ago

I'm having this issue now. Is it fixed in an upcoming version?

l-7-l commented 1 year ago

@tech6hutch It doesn't seem to be fixed yet. rust-analyzer#6541

tech6hutch commented 1 year ago

Oh okay, so it's not a num_enum issue, it's a rust-analyzer issue. I see there are no warnings when I run cargo check.

l-7-l commented 1 year ago

@tech6hutch It looks like so.