pub static DEPRECATED_SAFE_2024: &'static Lint
Expand description
The deprecated_safe_2024
lint detects unsafe functions being used as
safe functions.
§Example
#![deny(deprecated_safe)]
// edition 2021
use std::env;
fn enable_backtrace() {
env::set_var("RUST_BACKTRACE", "1");
}
{{produces}}
§Explanation
Rust editions allow the language to evolve without breaking backward
compatibility. This lint catches code that uses unsafe
functions that
were declared as safe (non-unsafe
) in editions prior to Rust 2024. If
you switch the compiler to Rust 2024 without updating the code, then it
will fail to compile if you are using a function previously marked as
safe.
You can audit the code to see if it suffices the preconditions of the
unsafe
code, and if it does, you can wrap it in an unsafe
block. If
you can’t fulfill the preconditions, you probably need to switch to a
different way of doing what you want to achieve.
This lint can automatically wrap the calls in unsafe
blocks, but this
obviously cannot verify that the preconditions of the unsafe
functions are fulfilled, so that is still up to the user.
The lint is currently “allow” by default, but that might change in the future.