rust/tests/ui/rust-2024/unsafe-env-suggestion.fixed
Tobias Bucher 4f5fb3126f Add TODO comment to unsafe env modification
Addresses https://github.com/rust-lang/rust/pull/124636#issuecomment-2132119534.

I think that the diff display regresses a little, because it's no longer
showing the `+` to show where the `unsafe {}` is added. I think it's
still fine.
2024-06-12 17:51:18 +02:00

23 lines
640 B
Rust

//@ run-rustfix
#![deny(deprecated_safe)]
use std::env;
#[deny(unused_unsafe)]
fn main() {
// TODO: Audit that the environment access only happens in single-threaded code.
unsafe { env::set_var("FOO", "BAR") };
//~^ ERROR call to deprecated safe function
//~| WARN this is accepted in the current edition
// TODO: Audit that the environment access only happens in single-threaded code.
unsafe { env::remove_var("FOO") };
//~^ ERROR call to deprecated safe function
//~| WARN this is accepted in the current edition
unsafe {
env::set_var("FOO", "BAR");
env::remove_var("FOO");
}
}