Skip to content

allow(dead_code) does not work for static externs #38780

@Wilfred

Description

@Wilfred

The following Rust code:

extern "C" {
    #[allow(dead_code)]
    static Qt: u64;
}

fn main() {
    println!("hello world");
}

produces the warning:

warning: foreign static item is never used: `Qt`, #[warn(dead_code)] on by default

in spite of the allow(dead_code) annotation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lints

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions