MISSING_UNSAFE_ON_EXTERN in rustc_lint::builtin - Rust
Description: The `missing_unsafe_on_extern` lint detects missing unsafe keyword on extern declarations.

Skip to main content

## MISSING_UNSAFE_ON_EXTERN

# Static MISSING_UNSAFE_ON_EXTERN

Source

    pub static MISSING_UNSAFE_ON_EXTERN: &'static Lint

Expand description

The `missing_unsafe_on_extern` lint detects missing unsafe keyword on extern declarations.

#### §Example

ⓘ

    #![warn(missing_unsafe_on_extern)]
    #![allow(dead_code)]

    extern "C" {
        fn foo(_: i32);
    }

    fn main() {}

{{produces}}

#### §Explanation

Declaring extern items, even without ever using them, can cause Undefined Behavior. We should consider all sources of Undefined Behavior to be unsafe.

This is a future-incompatible lint to transition this to a hard error in the future.