Skip to content

Commit 43afafc

Browse files
committed
run-make-support: add #[must_use] annotations
1 parent cc37e3c commit 43afafc

File tree

8 files changed

+26
-0
lines changed

8 files changed

+26
-0
lines changed

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

+1
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

+1
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

+3
Original file line numberDiff line numberDiff line change
@@ -148,14 +148,17 @@ pub struct CompletedProcess {
148148
}
149149

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

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

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

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

+1
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

+17
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ pub use rustc::{aux_build, rustc, Rustc};
3535
pub use rustdoc::{bare_rustdoc, rustdoc, Rustdoc};
3636

3737
#[track_caller]
38+
#[must_use]
3839
pub fn env_var(name: &str) -> String {
3940
match env::var(name) {
4041
Ok(v) => v,
@@ -43,6 +44,7 @@ pub fn env_var(name: &str) -> String {
4344
}
4445

4546
#[track_caller]
47+
#[must_use]
4648
pub fn env_var_os(name: &str) -> OsString {
4749
match env::var_os(name) {
4850
Some(v) => v,
@@ -51,32 +53,38 @@ pub fn env_var_os(name: &str) -> OsString {
5153
}
5254

5355
/// `TARGET`
56+
#[must_use]
5457
pub fn target() -> String {
5558
env_var("TARGET")
5659
}
5760

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

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

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

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

7986
#[track_caller]
87+
#[must_use]
8088
pub fn htmldocck() -> Command {
8189
let mut python = python_command();
8290
python.arg(source_root().join("src/etc/htmldocck.py"));
@@ -89,11 +97,13 @@ pub fn path<P: AsRef<Path>>(p: P) -> PathBuf {
8997
}
9098

9199
/// Path to the root rust-lang/rust source checkout.
100+
#[must_use]
92101
pub fn source_root() -> PathBuf {
93102
env_var("SOURCE_ROOT").into()
94103
}
95104

96105
/// Construct the static library name based on the platform.
106+
#[must_use]
97107
pub fn static_lib_name(name: &str) -> String {
98108
// See tools.mk (irrelevant lines omitted):
99109
//
@@ -118,6 +128,7 @@ pub fn static_lib_name(name: &str) -> String {
118128
}
119129

120130
/// Construct the dynamic library name based on the platform.
131+
#[must_use]
121132
pub fn dynamic_lib_name(name: &str) -> String {
122133
// See tools.mk (irrelevant lines omitted):
123134
//
@@ -144,6 +155,7 @@ pub fn dynamic_lib_name(name: &str) -> String {
144155
}
145156
}
146157

158+
#[must_use]
147159
pub fn dynamic_lib_extension() -> &'static str {
148160
if is_darwin() {
149161
"dylib"
@@ -155,23 +167,27 @@ pub fn dynamic_lib_extension() -> &'static str {
155167
}
156168

157169
/// Generate the name a rust library (rlib) would have.
170+
#[must_use]
158171
pub fn rust_lib_name(name: &str) -> String {
159172
format!("lib{name}.rlib")
160173
}
161174

162175
/// Construct the binary name based on platform.
176+
#[must_use]
163177
pub fn bin_name(name: &str) -> String {
164178
if is_windows() { format!("{name}.exe") } else { name.to_string() }
165179
}
166180

167181
/// Return the current working directory.
182+
#[must_use]
168183
pub fn cwd() -> PathBuf {
169184
env::current_dir().unwrap()
170185
}
171186

172187
/// Use `cygpath -w` on a path to get a Windows path string back. This assumes that `cygpath` is
173188
/// available on the platform!
174189
#[track_caller]
190+
#[must_use]
175191
pub fn cygpath_windows<P: AsRef<Path>>(path: P) -> String {
176192
let caller = panic::Location::caller();
177193
let mut cygpath = Command::new("cygpath");
@@ -187,6 +203,7 @@ pub fn cygpath_windows<P: AsRef<Path>>(path: P) -> String {
187203

188204
/// Run `uname`. This assumes that `uname` is available on the platform!
189205
#[track_caller]
206+
#[must_use]
190207
pub fn uname() -> String {
191208
let caller = panic::Location::caller();
192209
let mut uname = Command::new("uname");

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

+1
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

+1
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

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ pub fn rustdoc() -> Rustdoc {
1717
}
1818

1919
#[derive(Debug)]
20+
#[must_use]
2021
pub struct Rustdoc {
2122
cmd: Command,
2223
}

0 commit comments

Comments
 (0)