Skip to content

Commit 73498ba

Browse files
committed
run-make-support: add #[must_use] annotations
1 parent e75763a commit 73498ba

File tree

8 files changed

+26
-0
lines changed

8 files changed

+26
-0
lines changed

src/tools/run-make-support/src/cc.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ pub fn cc() -> Cc {
1515
/// A platform-specific C compiler invocation builder. The specific C compiler used is
1616
/// passed down from compiletest.
1717
#[derive(Debug)]
18+
#[must_use]
1819
pub struct Cc {
1920
cmd: Command,
2021
}

src/tools/run-make-support/src/clang.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ pub fn clang() -> Clang {
1111

1212
/// A `clang` invocation builder.
1313
#[derive(Debug)]
14+
#[must_use]
1415
pub struct Clang {
1516
cmd: Command,
1617
}

src/tools/run-make-support/src/command.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,14 +149,17 @@ pub struct CompletedProcess {
149149
}
150150

151151
impl CompletedProcess {
152+
#[must_use]
152153
pub fn stdout_utf8(&self) -> String {
153154
String::from_utf8(self.output.stdout.clone()).expect("stdout is not valid UTF-8")
154155
}
155156

157+
#[must_use]
156158
pub fn stderr_utf8(&self) -> String {
157159
String::from_utf8(self.output.stderr.clone()).expect("stderr is not valid UTF-8")
158160
}
159161

162+
#[must_use]
160163
pub fn status(&self) -> ExitStatus {
161164
self.output.status
162165
}

src/tools/run-make-support/src/diff/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ pub fn diff() -> Diff {
1313
}
1414

1515
#[derive(Debug)]
16+
#[must_use]
1617
pub struct Diff {
1718
expected: Option<String>,
1819
expected_name: Option<String>,

src/tools/run-make-support/src/lib.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ pub use rustc::{aux_build, rustc, Rustc};
3434
pub use rustdoc::{bare_rustdoc, rustdoc, Rustdoc};
3535

3636
#[track_caller]
37+
#[must_use]
3738
pub fn env_var(name: &str) -> String {
3839
match env::var(name) {
3940
Ok(v) => v,
@@ -42,6 +43,7 @@ pub fn env_var(name: &str) -> String {
4243
}
4344

4445
#[track_caller]
46+
#[must_use]
4547
pub fn env_var_os(name: &str) -> OsString {
4648
match env::var_os(name) {
4749
Some(v) => v,
@@ -50,44 +52,52 @@ pub fn env_var_os(name: &str) -> OsString {
5052
}
5153

5254
/// `TARGET`
55+
#[must_use]
5356
pub fn target() -> String {
5457
env_var("TARGET")
5558
}
5659

5760
/// Check if target is windows-like.
61+
#[must_use]
5862
pub fn is_windows() -> bool {
5963
target().contains("windows")
6064
}
6165

6266
/// Check if target uses msvc.
67+
#[must_use]
6368
pub fn is_msvc() -> bool {
6469
target().contains("msvc")
6570
}
6671

6772
/// Check if target uses macOS.
73+
#[must_use]
6874
pub fn is_darwin() -> bool {
6975
target().contains("darwin")
7076
}
7177

7278
#[track_caller]
79+
#[must_use]
7380
pub fn python_command() -> Command {
7481
let python_path = env_var("PYTHON");
7582
Command::new(python_path)
7683
}
7784

7885
#[track_caller]
86+
#[must_use]
7987
pub fn htmldocck() -> Command {
8088
let mut python = python_command();
8189
python.arg(source_root().join("src/etc/htmldocck.py"));
8290
python
8391
}
8492

8593
/// Path to the root rust-lang/rust source checkout.
94+
#[must_use]
8695
pub fn source_root() -> PathBuf {
8796
env_var("SOURCE_ROOT").into()
8897
}
8998

9099
/// Construct the static library name based on the platform.
100+
#[must_use]
91101
pub fn static_lib_name(name: &str) -> String {
92102
// See tools.mk (irrelevant lines omitted):
93103
//
@@ -112,6 +122,7 @@ pub fn static_lib_name(name: &str) -> String {
112122
}
113123

114124
/// Construct the dynamic library name based on the platform.
125+
#[must_use]
115126
pub fn dynamic_lib_name(name: &str) -> String {
116127
// See tools.mk (irrelevant lines omitted):
117128
//
@@ -138,6 +149,7 @@ pub fn dynamic_lib_name(name: &str) -> String {
138149
}
139150
}
140151

152+
#[must_use]
141153
pub fn dynamic_lib_extension() -> &'static str {
142154
if is_darwin() {
143155
"dylib"
@@ -149,23 +161,27 @@ pub fn dynamic_lib_extension() -> &'static str {
149161
}
150162

151163
/// Construct a rust library (rlib) name.
164+
#[must_use]
152165
pub fn rust_lib_name(name: &str) -> String {
153166
format!("lib{name}.rlib")
154167
}
155168

156169
/// Construct the binary name based on platform.
170+
#[must_use]
157171
pub fn bin_name(name: &str) -> String {
158172
if is_windows() { format!("{name}.exe") } else { name.to_string() }
159173
}
160174

161175
/// Return the current working directory.
176+
#[must_use]
162177
pub fn cwd() -> PathBuf {
163178
env::current_dir().unwrap()
164179
}
165180

166181
/// Use `cygpath -w` on a path to get a Windows path string back. This assumes that `cygpath` is
167182
/// available on the platform!
168183
#[track_caller]
184+
#[must_use]
169185
pub fn cygpath_windows<P: AsRef<Path>>(path: P) -> String {
170186
let caller = panic::Location::caller();
171187
let mut cygpath = Command::new("cygpath");
@@ -181,6 +197,7 @@ pub fn cygpath_windows<P: AsRef<Path>>(path: P) -> String {
181197

182198
/// Run `uname`. This assumes that `uname` is available on the platform!
183199
#[track_caller]
200+
#[must_use]
184201
pub fn uname() -> String {
185202
let caller = panic::Location::caller();
186203
let mut uname = Command::new("uname");

src/tools/run-make-support/src/llvm_readobj.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ pub fn llvm_readobj() -> LlvmReadobj {
1212

1313
/// A `llvm-readobj` invocation builder.
1414
#[derive(Debug)]
15+
#[must_use]
1516
pub struct LlvmReadobj {
1617
cmd: Command,
1718
}

src/tools/run-make-support/src/rustc.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ pub fn aux_build() -> Rustc {
1818

1919
/// A `rustc` invocation builder.
2020
#[derive(Debug)]
21+
#[must_use]
2122
pub struct Rustc {
2223
cmd: Command,
2324
}

src/tools/run-make-support/src/rustdoc.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ pub fn rustdoc() -> Rustdoc {
1616
}
1717

1818
#[derive(Debug)]
19+
#[must_use]
1920
pub struct Rustdoc {
2021
cmd: Command,
2122
}

0 commit comments

Comments
 (0)