@@ -34,6 +34,7 @@ pub use rustc::{aux_build, rustc, Rustc};
3434pub use rustdoc:: { bare_rustdoc, rustdoc, Rustdoc } ;
3535
3636#[ track_caller]
37+ #[ must_use]
3738pub 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]
4547pub 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]
5356pub fn target ( ) -> String {
5457 env_var ( "TARGET" )
5558}
5659
5760/// Check if target is windows-like.
61+ #[ must_use]
5862pub fn is_windows ( ) -> bool {
5963 target ( ) . contains ( "windows" )
6064}
6165
6266/// Check if target uses msvc.
67+ #[ must_use]
6368pub fn is_msvc ( ) -> bool {
6469 target ( ) . contains ( "msvc" )
6570}
6671
6772/// Check if target uses macOS.
73+ #[ must_use]
6874pub fn is_darwin ( ) -> bool {
6975 target ( ) . contains ( "darwin" )
7076}
7177
7278#[ track_caller]
79+ #[ must_use]
7380pub fn python_command ( ) -> Command {
7481 let python_path = env_var ( "PYTHON" ) ;
7582 Command :: new ( python_path)
7683}
7784
7885#[ track_caller]
86+ #[ must_use]
7987pub 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]
8695pub 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]
91101pub 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]
115126pub 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]
141153pub 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]
152165pub 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]
157171pub 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]
162177pub 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]
169185pub 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]
184201pub fn uname ( ) -> String {
185202 let caller = panic:: Location :: caller ( ) ;
186203 let mut uname = Command :: new ( "uname" ) ;
0 commit comments