@@ -35,6 +35,7 @@ pub use rustc::{aux_build, rustc, Rustc};
35
35
pub use rustdoc:: { bare_rustdoc, rustdoc, Rustdoc } ;
36
36
37
37
#[ track_caller]
38
+ #[ must_use]
38
39
pub fn env_var ( name : & str ) -> String {
39
40
match env:: var ( name) {
40
41
Ok ( v) => v,
@@ -43,6 +44,7 @@ pub fn env_var(name: &str) -> String {
43
44
}
44
45
45
46
#[ track_caller]
47
+ #[ must_use]
46
48
pub fn env_var_os ( name : & str ) -> OsString {
47
49
match env:: var_os ( name) {
48
50
Some ( v) => v,
@@ -51,32 +53,38 @@ pub fn env_var_os(name: &str) -> OsString {
51
53
}
52
54
53
55
/// `TARGET`
56
+ #[ must_use]
54
57
pub fn target ( ) -> String {
55
58
env_var ( "TARGET" )
56
59
}
57
60
58
61
/// Check if target is windows-like.
62
+ #[ must_use]
59
63
pub fn is_windows ( ) -> bool {
60
64
target ( ) . contains ( "windows" )
61
65
}
62
66
63
67
/// Check if target uses msvc.
68
+ #[ must_use]
64
69
pub fn is_msvc ( ) -> bool {
65
70
target ( ) . contains ( "msvc" )
66
71
}
67
72
68
73
/// Check if target uses macOS.
74
+ #[ must_use]
69
75
pub fn is_darwin ( ) -> bool {
70
76
target ( ) . contains ( "darwin" )
71
77
}
72
78
73
79
#[ track_caller]
80
+ #[ must_use]
74
81
pub fn python_command ( ) -> Command {
75
82
let python_path = env_var ( "PYTHON" ) ;
76
83
Command :: new ( python_path)
77
84
}
78
85
79
86
#[ track_caller]
87
+ #[ must_use]
80
88
pub fn htmldocck ( ) -> Command {
81
89
let mut python = python_command ( ) ;
82
90
python. arg ( source_root ( ) . join ( "src/etc/htmldocck.py" ) ) ;
@@ -89,11 +97,13 @@ pub fn path<P: AsRef<Path>>(p: P) -> PathBuf {
89
97
}
90
98
91
99
/// Path to the root rust-lang/rust source checkout.
100
+ #[ must_use]
92
101
pub fn source_root ( ) -> PathBuf {
93
102
env_var ( "SOURCE_ROOT" ) . into ( )
94
103
}
95
104
96
105
/// Construct the static library name based on the platform.
106
+ #[ must_use]
97
107
pub fn static_lib_name ( name : & str ) -> String {
98
108
// See tools.mk (irrelevant lines omitted):
99
109
//
@@ -118,6 +128,7 @@ pub fn static_lib_name(name: &str) -> String {
118
128
}
119
129
120
130
/// Construct the dynamic library name based on the platform.
131
+ #[ must_use]
121
132
pub fn dynamic_lib_name ( name : & str ) -> String {
122
133
// See tools.mk (irrelevant lines omitted):
123
134
//
@@ -144,6 +155,7 @@ pub fn dynamic_lib_name(name: &str) -> String {
144
155
}
145
156
}
146
157
158
+ #[ must_use]
147
159
pub fn dynamic_lib_extension ( ) -> & ' static str {
148
160
if is_darwin ( ) {
149
161
"dylib"
@@ -155,23 +167,27 @@ pub fn dynamic_lib_extension() -> &'static str {
155
167
}
156
168
157
169
/// Generate the name a rust library (rlib) would have.
170
+ #[ must_use]
158
171
pub fn rust_lib_name ( name : & str ) -> String {
159
172
format ! ( "lib{name}.rlib" )
160
173
}
161
174
162
175
/// Construct the binary name based on platform.
176
+ #[ must_use]
163
177
pub fn bin_name ( name : & str ) -> String {
164
178
if is_windows ( ) { format ! ( "{name}.exe" ) } else { name. to_string ( ) }
165
179
}
166
180
167
181
/// Return the current working directory.
182
+ #[ must_use]
168
183
pub fn cwd ( ) -> PathBuf {
169
184
env:: current_dir ( ) . unwrap ( )
170
185
}
171
186
172
187
/// Use `cygpath -w` on a path to get a Windows path string back. This assumes that `cygpath` is
173
188
/// available on the platform!
174
189
#[ track_caller]
190
+ #[ must_use]
175
191
pub fn cygpath_windows < P : AsRef < Path > > ( path : P ) -> String {
176
192
let caller = panic:: Location :: caller ( ) ;
177
193
let mut cygpath = Command :: new ( "cygpath" ) ;
@@ -187,6 +203,7 @@ pub fn cygpath_windows<P: AsRef<Path>>(path: P) -> String {
187
203
188
204
/// Run `uname`. This assumes that `uname` is available on the platform!
189
205
#[ track_caller]
206
+ #[ must_use]
190
207
pub fn uname ( ) -> String {
191
208
let caller = panic:: Location :: caller ( ) ;
192
209
let mut uname = Command :: new ( "uname" ) ;
0 commit comments