@@ -34,6 +34,7 @@ pub use rustc::{aux_build, rustc, Rustc};
34
34
pub use rustdoc:: { bare_rustdoc, rustdoc, Rustdoc } ;
35
35
36
36
#[ track_caller]
37
+ #[ must_use]
37
38
pub fn env_var ( name : & str ) -> String {
38
39
match env:: var ( name) {
39
40
Ok ( v) => v,
@@ -42,6 +43,7 @@ pub fn env_var(name: &str) -> String {
42
43
}
43
44
44
45
#[ track_caller]
46
+ #[ must_use]
45
47
pub fn env_var_os ( name : & str ) -> OsString {
46
48
match env:: var_os ( name) {
47
49
Some ( v) => v,
@@ -50,44 +52,52 @@ pub fn env_var_os(name: &str) -> OsString {
50
52
}
51
53
52
54
/// `TARGET`
55
+ #[ must_use]
53
56
pub fn target ( ) -> String {
54
57
env_var ( "TARGET" )
55
58
}
56
59
57
60
/// Check if target is windows-like.
61
+ #[ must_use]
58
62
pub fn is_windows ( ) -> bool {
59
63
target ( ) . contains ( "windows" )
60
64
}
61
65
62
66
/// Check if target uses msvc.
67
+ #[ must_use]
63
68
pub fn is_msvc ( ) -> bool {
64
69
target ( ) . contains ( "msvc" )
65
70
}
66
71
67
72
/// Check if target uses macOS.
73
+ #[ must_use]
68
74
pub fn is_darwin ( ) -> bool {
69
75
target ( ) . contains ( "darwin" )
70
76
}
71
77
72
78
#[ track_caller]
79
+ #[ must_use]
73
80
pub fn python_command ( ) -> Command {
74
81
let python_path = env_var ( "PYTHON" ) ;
75
82
Command :: new ( python_path)
76
83
}
77
84
78
85
#[ track_caller]
86
+ #[ must_use]
79
87
pub fn htmldocck ( ) -> Command {
80
88
let mut python = python_command ( ) ;
81
89
python. arg ( source_root ( ) . join ( "src/etc/htmldocck.py" ) ) ;
82
90
python
83
91
}
84
92
85
93
/// Path to the root rust-lang/rust source checkout.
94
+ #[ must_use]
86
95
pub fn source_root ( ) -> PathBuf {
87
96
env_var ( "SOURCE_ROOT" ) . into ( )
88
97
}
89
98
90
99
/// Construct the static library name based on the platform.
100
+ #[ must_use]
91
101
pub fn static_lib_name ( name : & str ) -> String {
92
102
// See tools.mk (irrelevant lines omitted):
93
103
//
@@ -112,6 +122,7 @@ pub fn static_lib_name(name: &str) -> String {
112
122
}
113
123
114
124
/// Construct the dynamic library name based on the platform.
125
+ #[ must_use]
115
126
pub fn dynamic_lib_name ( name : & str ) -> String {
116
127
// See tools.mk (irrelevant lines omitted):
117
128
//
@@ -138,6 +149,7 @@ pub fn dynamic_lib_name(name: &str) -> String {
138
149
}
139
150
}
140
151
152
+ #[ must_use]
141
153
pub fn dynamic_lib_extension ( ) -> & ' static str {
142
154
if is_darwin ( ) {
143
155
"dylib"
@@ -149,23 +161,27 @@ pub fn dynamic_lib_extension() -> &'static str {
149
161
}
150
162
151
163
/// Construct a rust library (rlib) name.
164
+ #[ must_use]
152
165
pub fn rust_lib_name ( name : & str ) -> String {
153
166
format ! ( "lib{name}.rlib" )
154
167
}
155
168
156
169
/// Construct the binary name based on platform.
170
+ #[ must_use]
157
171
pub fn bin_name ( name : & str ) -> String {
158
172
if is_windows ( ) { format ! ( "{name}.exe" ) } else { name. to_string ( ) }
159
173
}
160
174
161
175
/// Return the current working directory.
176
+ #[ must_use]
162
177
pub fn cwd ( ) -> PathBuf {
163
178
env:: current_dir ( ) . unwrap ( )
164
179
}
165
180
166
181
/// Use `cygpath -w` on a path to get a Windows path string back. This assumes that `cygpath` is
167
182
/// available on the platform!
168
183
#[ track_caller]
184
+ #[ must_use]
169
185
pub fn cygpath_windows < P : AsRef < Path > > ( path : P ) -> String {
170
186
let caller = panic:: Location :: caller ( ) ;
171
187
let mut cygpath = Command :: new ( "cygpath" ) ;
@@ -181,6 +197,7 @@ pub fn cygpath_windows<P: AsRef<Path>>(path: P) -> String {
181
197
182
198
/// Run `uname`. This assumes that `uname` is available on the platform!
183
199
#[ track_caller]
200
+ #[ must_use]
184
201
pub fn uname ( ) -> String {
185
202
let caller = panic:: Location :: caller ( ) ;
186
203
let mut uname = Command :: new ( "uname" ) ;
0 commit comments