From a443dc4ecdc2e85fbfabdd972028d51616ee20c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=AE=B8=E6=9D=B0=E5=8F=8B=20Jieyou=20Xu=20=28Joe=29?= Date: Wed, 17 Jul 2024 11:17:28 +0000 Subject: [PATCH] run_make_support: rename `env_checked` -> `env` --- src/tools/run-make-support/src/{env_checked.rs => env.rs} | 5 ++--- src/tools/run-make-support/src/external_deps/llvm.rs | 2 +- src/tools/run-make-support/src/external_deps/python.rs | 2 +- src/tools/run-make-support/src/external_deps/rustc.rs | 2 +- src/tools/run-make-support/src/external_deps/rustdoc.rs | 2 +- src/tools/run-make-support/src/lib.rs | 4 ++-- src/tools/run-make-support/src/path_helpers.rs | 2 +- src/tools/run-make-support/src/util.rs | 2 +- 8 files changed, 10 insertions(+), 11 deletions(-) rename src/tools/run-make-support/src/{env_checked.rs => env.rs} (84%) diff --git a/src/tools/run-make-support/src/env_checked.rs b/src/tools/run-make-support/src/env.rs similarity index 84% rename from src/tools/run-make-support/src/env_checked.rs rename to src/tools/run-make-support/src/env.rs index 9f9d2445ef66..f52524e7d54c 100644 --- a/src/tools/run-make-support/src/env_checked.rs +++ b/src/tools/run-make-support/src/env.rs @@ -1,10 +1,9 @@ -use std::env; use std::ffi::OsString; #[track_caller] #[must_use] pub fn env_var(name: &str) -> String { - match env::var(name) { + match std::env::var(name) { Ok(v) => v, Err(err) => panic!("failed to retrieve environment variable {name:?}: {err:?}"), } @@ -13,7 +12,7 @@ pub fn env_var(name: &str) -> String { #[track_caller] #[must_use] pub fn env_var_os(name: &str) -> OsString { - match env::var_os(name) { + match std::env::var_os(name) { Some(v) => v, None => panic!("failed to retrieve environment variable {name:?}"), } diff --git a/src/tools/run-make-support/src/external_deps/llvm.rs b/src/tools/run-make-support/src/external_deps/llvm.rs index 9c821dfc03d2..5e8ad7ed3125 100644 --- a/src/tools/run-make-support/src/external_deps/llvm.rs +++ b/src/tools/run-make-support/src/external_deps/llvm.rs @@ -1,7 +1,7 @@ use std::path::{Path, PathBuf}; use crate::command::Command; -use crate::env_checked::env_var; +use crate::env::env_var; /// Construct a new `llvm-readobj` invocation with the `GNU` output style. /// This assumes that `llvm-readobj` is available at `$LLVM_BIN_DIR/llvm-readobj`. diff --git a/src/tools/run-make-support/src/external_deps/python.rs b/src/tools/run-make-support/src/external_deps/python.rs index 59e725fd73e9..fb885069371b 100644 --- a/src/tools/run-make-support/src/external_deps/python.rs +++ b/src/tools/run-make-support/src/external_deps/python.rs @@ -1,5 +1,5 @@ use crate::command::Command; -use crate::env_checked::env_var; +use crate::env::env_var; /// Obtain path of python as provided by the `PYTHON` environment variable. It is up to the caller /// to document and check if the python version is compatible with its intended usage. diff --git a/src/tools/run-make-support/src/external_deps/rustc.rs b/src/tools/run-make-support/src/external_deps/rustc.rs index ce04caf6d341..71d28dd9675f 100644 --- a/src/tools/run-make-support/src/external_deps/rustc.rs +++ b/src/tools/run-make-support/src/external_deps/rustc.rs @@ -2,7 +2,7 @@ use std::ffi::{OsStr, OsString}; use std::path::Path; use crate::command::Command; -use crate::env_checked::env_var; +use crate::env::env_var; use crate::path_helpers::cwd; use crate::util::set_host_rpath; diff --git a/src/tools/run-make-support/src/external_deps/rustdoc.rs b/src/tools/run-make-support/src/external_deps/rustdoc.rs index db324f07c7e9..96c2218a563e 100644 --- a/src/tools/run-make-support/src/external_deps/rustdoc.rs +++ b/src/tools/run-make-support/src/external_deps/rustdoc.rs @@ -2,7 +2,7 @@ use std::ffi::OsStr; use std::path::Path; use crate::command::Command; -use crate::env_checked::{env_var, env_var_os}; +use crate::env::{env_var, env_var_os}; use crate::util::set_host_rpath; /// Construct a plain `rustdoc` invocation with no flags set. diff --git a/src/tools/run-make-support/src/lib.rs b/src/tools/run-make-support/src/lib.rs index 5befea533515..38070f79edc5 100644 --- a/src/tools/run-make-support/src/lib.rs +++ b/src/tools/run-make-support/src/lib.rs @@ -10,7 +10,7 @@ mod util; pub mod artifact_names; pub mod assertion_helpers; pub mod diff; -pub mod env_checked; +pub mod env; pub mod external_deps; pub mod fs_helpers; pub mod fs_wrapper; @@ -48,7 +48,7 @@ pub use rustdoc::{bare_rustdoc, rustdoc, Rustdoc}; pub use diff::{diff, Diff}; /// Panic-on-fail [`std::env::var`] and [`std::env::var_os`] wrappers. -pub use env_checked::{env_var, env_var_os}; +pub use env::{env_var, env_var_os}; /// Convenience helpers for running binaries and other commands. pub use run::{cmd, run, run_fail, run_with_args}; diff --git a/src/tools/run-make-support/src/path_helpers.rs b/src/tools/run-make-support/src/path_helpers.rs index a35c32cbe48b..f46368b53f8b 100644 --- a/src/tools/run-make-support/src/path_helpers.rs +++ b/src/tools/run-make-support/src/path_helpers.rs @@ -4,7 +4,7 @@ use std::panic; use std::path::{Path, PathBuf}; use crate::command::Command; -use crate::env_checked::env_var; +use crate::env::env_var; use crate::util::handle_failed_output; /// Return the current working directory. diff --git a/src/tools/run-make-support/src/util.rs b/src/tools/run-make-support/src/util.rs index 9ed92ac41567..703e3ad1c6cd 100644 --- a/src/tools/run-make-support/src/util.rs +++ b/src/tools/run-make-support/src/util.rs @@ -1,7 +1,7 @@ use std::path::PathBuf; use crate::command::{Command, CompletedProcess}; -use crate::env_checked::env_var; +use crate::env::env_var; use crate::path_helpers::cwd; /// If a given [`Command`] failed (as indicated by its [`CompletedProcess`]), verbose print the