diff --git a/compiler/rustc_feature/src/tests.rs b/compiler/rustc_feature/src/tests.rs index 50433e44b1350..eb7dce94a0595 100644 --- a/compiler/rustc_feature/src/tests.rs +++ b/compiler/rustc_feature/src/tests.rs @@ -1,6 +1,7 @@ use super::UnstableFeatures; #[test] +#[allow(deprecated, deprecated_in_future)] fn rustc_bootstrap_parsing() { let is_bootstrap = |env, krate| { std::env::set_var("RUSTC_BOOTSTRAP", env); diff --git a/compiler/rustc_interface/src/passes.rs b/compiler/rustc_interface/src/passes.rs index b073ee9682fbd..beaf15a4762fe 100644 --- a/compiler/rustc_interface/src/passes.rs +++ b/compiler/rustc_interface/src/passes.rs @@ -257,6 +257,7 @@ fn pre_expansion_lint( /// syntax expansion, secondary `cfg` expansion, synthesis of a test /// harness if one is to be provided, injection of a dependency on the /// standard library and prelude, and name resolution. +#[allow(deprecated, deprecated_in_future)] pub fn configure_and_expand( sess: &Session, lint_store: &LintStore, diff --git a/library/std/src/env.rs b/library/std/src/env.rs index c6af708f6cd0a..4fd3b0c77dba4 100644 --- a/library/std/src/env.rs +++ b/library/std/src/env.rs @@ -327,6 +327,10 @@ impl Error for VarError { /// assert_eq!(env::var(key), Ok("VALUE".to_string())); /// ``` #[stable(feature = "env", since = "1.0.0")] +#[rustc_deprecated( + since = "1.58.0", + reason = "unclear soundness on POSIX, use `libc::setenv` or `std::process::Command::env` instead" +)] pub fn set_var, V: AsRef>(key: K, value: V) { _set_var(key.as_ref(), value.as_ref()) } @@ -369,6 +373,10 @@ fn _set_var(key: &OsStr, value: &OsStr) { /// assert!(env::var(key).is_err()); /// ``` #[stable(feature = "env", since = "1.0.0")] +#[rustc_deprecated( + since = "1.58.0", + reason = "unclear soundness on POSIX, use `libc::unsetenv` or `std::process::Command::env_remove` instead" +)] pub fn remove_var>(key: K) { _remove_var(key.as_ref()) } diff --git a/library/std/src/process/tests.rs b/library/std/src/process/tests.rs index bc71c150550a4..3555a332328ab 100644 --- a/library/std/src/process/tests.rs +++ b/library/std/src/process/tests.rs @@ -260,6 +260,7 @@ fn test_add_to_env() { #[test] #[cfg_attr(target_os = "vxworks", ignore)] +#[allow(deprecated, deprecated_in_future)] fn test_capture_env_at_spawn() { use crate::env; diff --git a/library/std/src/sys/windows/process/tests.rs b/library/std/src/sys/windows/process/tests.rs index 3b65856dcaca6..b1aea13f36e56 100644 --- a/library/std/src/sys/windows/process/tests.rs +++ b/library/std/src/sys/windows/process/tests.rs @@ -73,6 +73,7 @@ fn test_make_command_line() { // On Windows, environment args are case preserving but comparisons are case-insensitive. // See: #85242 #[test] +#[allow(deprecated, deprecated_in_future)] fn windows_env_unicode_case() { let test_cases = [ ("ä", "Ä"), diff --git a/library/std/src/sys_common/process.rs b/library/std/src/sys_common/process.rs index 2cd1e29f6c45d..b11f5a52eb87f 100644 --- a/library/std/src/sys_common/process.rs +++ b/library/std/src/sys_common/process.rs @@ -40,6 +40,7 @@ impl CommandEnv { } // Apply these changes directly to the current environment + #[allow(deprecated, deprecated_in_future)] pub fn apply(&self) { if self.clear { for (k, _) in env::vars_os() { diff --git a/library/std/tests/env.rs b/library/std/tests/env.rs index b095c2dde6285..2874b9be3368f 100644 --- a/library/std/tests/env.rs +++ b/library/std/tests/env.rs @@ -1,3 +1,5 @@ +#![allow(deprecated, deprecated_in_future)] + use std::env::*; use std::ffi::{OsStr, OsString}; diff --git a/library/test/src/lib.rs b/library/test/src/lib.rs index 99d951d8016bb..4a46bc9373941 100644 --- a/library/test/src/lib.rs +++ b/library/test/src/lib.rs @@ -151,6 +151,7 @@ pub fn test_main_static(tests: &[&TestDescAndFn]) { /// /// This is the entry point for the main function generated by `rustc --test` /// when panic=abort. +#[allow(deprecated, deprecated_in_future)] pub fn test_main_static_abort(tests: &[&TestDescAndFn]) { // If we're being run in SpawnedSecondary mode, run the test here. run_test // will then exit the process. diff --git a/library/test/src/term/terminfo/searcher/tests.rs b/library/test/src/term/terminfo/searcher/tests.rs index 4227a585e2f59..297029943d7cd 100644 --- a/library/test/src/term/terminfo/searcher/tests.rs +++ b/library/test/src/term/terminfo/searcher/tests.rs @@ -2,6 +2,7 @@ use super::*; #[test] #[ignore = "buildbots don't have ncurses installed and I can't mock everything I need"] +#[allow(deprecated, deprecated_in_future)] fn test_get_dbpath_for_term() { // woefully inadequate test coverage // note: current tests won't work with non-standard terminfo hierarchies (e.g., macOS's) diff --git a/src/build_helper/lib.rs b/src/build_helper/lib.rs index b1ec072f3f8aa..21e0038dbd843 100644 --- a/src/build_helper/lib.rs +++ b/src/build_helper/lib.rs @@ -46,6 +46,7 @@ pub fn tracked_env_var_os + Display>(key: K) -> Option // the one we want to use. As such, we restore the environment to what bootstrap saw. This isn't // perfect -- we might actually want to see something from Cargo's added library paths -- but // for now it works. +#[allow(deprecated, deprecated_in_future)] pub fn restore_library_path() { let key = tracked_env_var_os("REAL_LIBRARY_PATH_VAR").expect("REAL_LIBRARY_PATH_VAR"); if let Some(env) = tracked_env_var_os("REAL_LIBRARY_PATH") { diff --git a/src/test/ui/command/command-exec.rs b/src/test/ui/command/command-exec.rs index 0af87214f9523..f24527f57974e 100644 --- a/src/test/ui/command/command-exec.rs +++ b/src/test/ui/command/command-exec.rs @@ -12,6 +12,7 @@ use std::env; use std::os::unix::process::CommandExt; use std::process::Command; +#[allow(deprecated, deprecated_in_future)] fn main() { let mut args = env::args(); let me = args.next().unwrap(); diff --git a/src/test/ui/process/process-envs.rs b/src/test/ui/process/process-envs.rs index 8fc99b23fd210..cd5ecfd8c0faf 100644 --- a/src/test/ui/process/process-envs.rs +++ b/src/test/ui/process/process-envs.rs @@ -25,6 +25,7 @@ pub fn env_cmd() -> Command { cmd } +#[allow(deprecated, deprecated_in_future)] fn main() { // save original environment let old_env = env::var_os("RUN_TEST_NEW_ENV"); diff --git a/src/test/ui/process/process-remove-from-env.rs b/src/test/ui/process/process-remove-from-env.rs index af4e49dfdbb5b..a468bd3bb9259 100644 --- a/src/test/ui/process/process-remove-from-env.rs +++ b/src/test/ui/process/process-remove-from-env.rs @@ -24,6 +24,7 @@ pub fn env_cmd() -> Command { cmd } +#[allow(deprecated, deprecated_in_future)] fn main() { // save original environment let old_env = env::var_os("RUN_TEST_NEW_ENV"); diff --git a/src/test/ui/std-backtrace.rs b/src/test/ui/std-backtrace.rs index b5e76666af1f8..211f9fbf02f28 100644 --- a/src/test/ui/std-backtrace.rs +++ b/src/test/ui/std-backtrace.rs @@ -24,6 +24,7 @@ fn main() { } } +#[allow(deprecated, deprecated_in_future)] fn runtest(me: &str) { env::remove_var("RUST_BACKTRACE"); env::remove_var("RUST_LIB_BACKTRACE");