diff options
| author | 许杰友 Jieyou Xu (Joe) <jieyouxu@outlook.com> | 2024-06-11 21:02:54 +0000 |
|---|---|---|
| committer | 许杰友 Jieyou Xu (Joe) <jieyouxu@outlook.com> | 2024-06-11 21:31:08 +0000 |
| commit | 43afafcdb37d5a47d6b4139175bb667ade0d6784 (patch) | |
| tree | fcfd697e354ae0bd8f649b73384ff7d0c62e7a33 | |
| parent | cc37e3c1828a3033c116f239a6540e1bf5fad96d (diff) | |
| download | rust-43afafcdb37d5a47d6b4139175bb667ade0d6784.tar.gz rust-43afafcdb37d5a47d6b4139175bb667ade0d6784.zip | |
run-make-support: add #[must_use] annotations
| -rw-r--r-- | src/tools/run-make-support/src/cc.rs | 1 | ||||
| -rw-r--r-- | src/tools/run-make-support/src/clang.rs | 1 | ||||
| -rw-r--r-- | src/tools/run-make-support/src/command.rs | 3 | ||||
| -rw-r--r-- | src/tools/run-make-support/src/diff/mod.rs | 1 | ||||
| -rw-r--r-- | src/tools/run-make-support/src/lib.rs | 17 | ||||
| -rw-r--r-- | src/tools/run-make-support/src/llvm_readobj.rs | 1 | ||||
| -rw-r--r-- | src/tools/run-make-support/src/rustc.rs | 1 | ||||
| -rw-r--r-- | src/tools/run-make-support/src/rustdoc.rs | 1 |
8 files changed, 26 insertions, 0 deletions
diff --git a/src/tools/run-make-support/src/cc.rs b/src/tools/run-make-support/src/cc.rs index 8694740cfc3..31b9e8a23b8 100644 --- a/src/tools/run-make-support/src/cc.rs +++ b/src/tools/run-make-support/src/cc.rs @@ -15,6 +15,7 @@ pub fn cc() -> Cc { /// A platform-specific C compiler invocation builder. The specific C compiler used is /// passed down from compiletest. #[derive(Debug)] +#[must_use] pub struct Cc { cmd: Command, } diff --git a/src/tools/run-make-support/src/clang.rs b/src/tools/run-make-support/src/clang.rs index a31004659c1..c23e41ebe21 100644 --- a/src/tools/run-make-support/src/clang.rs +++ b/src/tools/run-make-support/src/clang.rs @@ -11,6 +11,7 @@ pub fn clang() -> Clang { /// A `clang` invocation builder. #[derive(Debug)] +#[must_use] pub struct Clang { cmd: Command, } diff --git a/src/tools/run-make-support/src/command.rs b/src/tools/run-make-support/src/command.rs index d689dc2f979..7cbc61bdf33 100644 --- a/src/tools/run-make-support/src/command.rs +++ b/src/tools/run-make-support/src/command.rs @@ -148,14 +148,17 @@ pub struct CompletedProcess { } impl CompletedProcess { + #[must_use] pub fn stdout_utf8(&self) -> String { String::from_utf8(self.output.stdout.clone()).expect("stdout is not valid UTF-8") } + #[must_use] pub fn stderr_utf8(&self) -> String { String::from_utf8(self.output.stderr.clone()).expect("stderr is not valid UTF-8") } + #[must_use] pub fn status(&self) -> ExitStatus { self.output.status } diff --git a/src/tools/run-make-support/src/diff/mod.rs b/src/tools/run-make-support/src/diff/mod.rs index 0fb6fec9d58..105cdbc7b32 100644 --- a/src/tools/run-make-support/src/diff/mod.rs +++ b/src/tools/run-make-support/src/diff/mod.rs @@ -13,6 +13,7 @@ pub fn diff() -> Diff { } #[derive(Debug)] +#[must_use] pub struct Diff { expected: Option<String>, expected_name: Option<String>, diff --git a/src/tools/run-make-support/src/lib.rs b/src/tools/run-make-support/src/lib.rs index b920f9a07db..9f8cd3bea7c 100644 --- a/src/tools/run-make-support/src/lib.rs +++ b/src/tools/run-make-support/src/lib.rs @@ -35,6 +35,7 @@ pub use rustc::{aux_build, rustc, Rustc}; pub use rustdoc::{bare_rustdoc, rustdoc, Rustdoc}; #[track_caller] +#[must_use] pub fn env_var(name: &str) -> String { match env::var(name) { Ok(v) => v, @@ -43,6 +44,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) { Some(v) => v, @@ -51,32 +53,38 @@ pub fn env_var_os(name: &str) -> OsString { } /// `TARGET` +#[must_use] pub fn target() -> String { env_var("TARGET") } /// Check if target is windows-like. +#[must_use] pub fn is_windows() -> bool { target().contains("windows") } /// Check if target uses msvc. +#[must_use] pub fn is_msvc() -> bool { target().contains("msvc") } /// Check if target uses macOS. +#[must_use] pub fn is_darwin() -> bool { target().contains("darwin") } #[track_caller] +#[must_use] pub fn python_command() -> Command { let python_path = env_var("PYTHON"); Command::new(python_path) } #[track_caller] +#[must_use] pub fn htmldocck() -> Command { let mut python = python_command(); python.arg(source_root().join("src/etc/htmldocck.py")); @@ -89,11 +97,13 @@ pub fn path<P: AsRef<Path>>(p: P) -> PathBuf { } /// Path to the root rust-lang/rust source checkout. +#[must_use] pub fn source_root() -> PathBuf { env_var("SOURCE_ROOT").into() } /// Construct the static library name based on the platform. +#[must_use] pub fn static_lib_name(name: &str) -> String { // See tools.mk (irrelevant lines omitted): // @@ -118,6 +128,7 @@ pub fn static_lib_name(name: &str) -> String { } /// Construct the dynamic library name based on the platform. +#[must_use] pub fn dynamic_lib_name(name: &str) -> String { // See tools.mk (irrelevant lines omitted): // @@ -144,6 +155,7 @@ pub fn dynamic_lib_name(name: &str) -> String { } } +#[must_use] pub fn dynamic_lib_extension() -> &'static str { if is_darwin() { "dylib" @@ -155,16 +167,19 @@ pub fn dynamic_lib_extension() -> &'static str { } /// Generate the name a rust library (rlib) would have. +#[must_use] pub fn rust_lib_name(name: &str) -> String { format!("lib{name}.rlib") } /// Construct the binary name based on platform. +#[must_use] pub fn bin_name(name: &str) -> String { if is_windows() { format!("{name}.exe") } else { name.to_string() } } /// Return the current working directory. +#[must_use] pub fn cwd() -> PathBuf { env::current_dir().unwrap() } @@ -172,6 +187,7 @@ pub fn cwd() -> PathBuf { /// Use `cygpath -w` on a path to get a Windows path string back. This assumes that `cygpath` is /// available on the platform! #[track_caller] +#[must_use] pub fn cygpath_windows<P: AsRef<Path>>(path: P) -> String { let caller = panic::Location::caller(); let mut cygpath = Command::new("cygpath"); @@ -187,6 +203,7 @@ pub fn cygpath_windows<P: AsRef<Path>>(path: P) -> String { /// Run `uname`. This assumes that `uname` is available on the platform! #[track_caller] +#[must_use] pub fn uname() -> String { let caller = panic::Location::caller(); let mut uname = Command::new("uname"); diff --git a/src/tools/run-make-support/src/llvm_readobj.rs b/src/tools/run-make-support/src/llvm_readobj.rs index 57ddfc205e6..3c719356e8f 100644 --- a/src/tools/run-make-support/src/llvm_readobj.rs +++ b/src/tools/run-make-support/src/llvm_readobj.rs @@ -12,6 +12,7 @@ pub fn llvm_readobj() -> LlvmReadobj { /// A `llvm-readobj` invocation builder. #[derive(Debug)] +#[must_use] pub struct LlvmReadobj { cmd: Command, } diff --git a/src/tools/run-make-support/src/rustc.rs b/src/tools/run-make-support/src/rustc.rs index 32fa5018d80..39950f43176 100644 --- a/src/tools/run-make-support/src/rustc.rs +++ b/src/tools/run-make-support/src/rustc.rs @@ -18,6 +18,7 @@ pub fn aux_build() -> Rustc { /// A `rustc` invocation builder. #[derive(Debug)] +#[must_use] pub struct Rustc { cmd: Command, } diff --git a/src/tools/run-make-support/src/rustdoc.rs b/src/tools/run-make-support/src/rustdoc.rs index 332906f739a..93078561254 100644 --- a/src/tools/run-make-support/src/rustdoc.rs +++ b/src/tools/run-make-support/src/rustdoc.rs @@ -17,6 +17,7 @@ pub fn rustdoc() -> Rustdoc { } #[derive(Debug)] +#[must_use] pub struct Rustdoc { cmd: Command, } |
