Skip to content

non_upper_case_globals lint should be suppressed for #[no_mangle] items #36258

Closed
@tomjakubowski

Description

@tomjakubowski
#[no_mangle]
pub static this_symbol_is_required_to_exist: i32 = 1;

fn main() {
}

Yields compiler warning:

warning: static constant `this_symbol_is_required_to_exist` should have an upper case name such as `THIS_SYMBOL_IS_REQUIRED_TO_EXIST`, #[warn(non_upper_case_globals)] on by default
 --> <anon>:2:1
  |
2 | pub static this_symbol_is_required_to_exist: i32 = 1;
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

I think #[no_mangle] is a good hint that the symbol's name (incl. capitalization) is important enough that stylistic lints should be disabled for it. The lint already ignores functions in extern "C" {} blocks, for example:

extern "C" {
    pub fn This_IS_WaCkYcapitalization();
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.C-feature-requestCategory: A feature request, i.e: not implemented / a PR.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions