@@ -35,6 +35,7 @@ pub use rustc::{aux_build, rustc, Rustc};
3535pub use rustdoc:: { bare_rustdoc, rustdoc, Rustdoc } ;
3636
3737#[ track_caller]
38+ #[ must_use]
3839pub 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]
4648pub 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]
5457pub fn target ( ) -> String {
5558 env_var ( "TARGET" )
5659}
5760
5861/// Check if target is windows-like.
62+ #[ must_use]
5963pub fn is_windows ( ) -> bool {
6064 target ( ) . contains ( "windows" )
6165}
6266
6367/// Check if target uses msvc.
68+ #[ must_use]
6469pub fn is_msvc ( ) -> bool {
6570 target ( ) . contains ( "msvc" )
6671}
6772
6873/// Check if target uses macOS.
74+ #[ must_use]
6975pub fn is_darwin ( ) -> bool {
7076 target ( ) . contains ( "darwin" )
7177}
7278
7379#[ track_caller]
80+ #[ must_use]
7481pub fn python_command ( ) -> Command {
7582 let python_path = env_var ( "PYTHON" ) ;
7683 Command :: new ( python_path)
7784}
7885
7986#[ track_caller]
87+ #[ must_use]
8088pub 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]
92101pub 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]
97107pub 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]
121132pub 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]
147159pub 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]
158171pub 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]
163177pub 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]
168183pub 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]
175191pub 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]
190207pub fn uname ( ) -> String {
191208 let caller = panic:: Location :: caller ( ) ;
192209 let mut uname = Command :: new ( "uname" ) ;
0 commit comments