How to disable camel case warnings

Viewed 8885

This wasn't on google, so I kindly ask someone how to supress this warning:

342 |     BAYER_RGGB16,
    |     ^^^^^^^^^^^^ help: convert the identifier to upper camel case: `BayerRggb16`

#[allow(non_snake_case)] doesn't work.

1 Answers

You're looking for the lint option non-camel-case-types. The description of this check from rustc -W help reads

                           name default meaning
non-camel-case-types warn types, variants, traits and type parameters should have camel case names

In your snippet, BAYER_RGGB16 appears to be an enum variant, so the default lint options require it to be named in (upper) CamelCase. This check can be disabled with the lint attribute #[allow(non_camel_case_types)]:

// Can also be applied to the whole enum, instead of just one variant.
// #[allow(non_camel_case_types)]
enum MyEnum {

    // ...

    #[allow(non_camel_case_types)]
    BAYER_RGGB16,
}

Try it yourself on the Rust Playground.

Related