@@ -68,14 +68,12 @@ pub fn submodule_path_of(builder: &Builder<'_>, path: &str) -> Option<String> {
68
68
}
69
69
70
70
fn is_aix_shared_archive ( path : & Path ) -> bool {
71
- let file = match fs:: File :: open ( path) {
72
- Ok ( file) => file,
73
- Err ( _) => return false ,
71
+ let Ok ( file) = fs:: File :: open ( path) else {
72
+ return false ;
74
73
} ;
75
74
let reader = object:: ReadCache :: new ( file) ;
76
- let archive = match ArchiveFile :: parse ( & reader) {
77
- Ok ( result) => result,
78
- Err ( _) => return false ,
75
+ let Ok ( archive) = ArchiveFile :: parse ( & reader) else {
76
+ return false ;
79
77
} ;
80
78
81
79
archive
@@ -99,10 +97,7 @@ pub fn libdir(target: TargetSelection) -> &'static str {
99
97
/// Adds a list of lookup paths to `cmd`'s dynamic library lookup path.
100
98
/// If the dylib_path_var is already set for this cmd, the old value will be overwritten!
101
99
pub fn add_dylib_path ( path : Vec < PathBuf > , cmd : & mut BootstrapCommand ) {
102
- let mut list = dylib_path ( ) ;
103
- for path in path {
104
- list. insert ( 0 , path) ;
105
- }
100
+ let list = path. into_iter ( ) . rev ( ) . chain ( dylib_path ( ) ) ;
106
101
cmd. env ( dylib_path_var ( ) , t ! ( env:: join_paths( list) ) ) ;
107
102
}
108
103
@@ -156,7 +151,7 @@ pub fn move_file<P: AsRef<Path>, Q: AsRef<Path>>(from: P, to: Q) -> io::Result<(
156
151
}
157
152
158
153
pub fn forcing_clang_based_tests ( ) -> bool {
159
- if let Some ( var ) = env:: var_os ( "RUSTBUILD_FORCE_CLANG_BASED_TESTS" ) {
154
+ env:: var_os ( "RUSTBUILD_FORCE_CLANG_BASED_TESTS" ) . is_some_and ( |var| {
160
155
match & var. to_string_lossy ( ) . to_lowercase ( ) [ ..] {
161
156
"1" | "yes" | "on" => true ,
162
157
"0" | "no" | "off" => false ,
@@ -168,9 +163,7 @@ pub fn forcing_clang_based_tests() -> bool {
168
163
)
169
164
}
170
165
}
171
- } else {
172
- false
173
- }
166
+ } )
174
167
}
175
168
176
169
pub fn use_host_linker ( target : TargetSelection ) -> bool {
@@ -206,10 +199,7 @@ pub fn is_valid_test_suite_arg<'a, P: AsRef<Path>>(
206
199
builder : & Builder < ' _ > ,
207
200
) -> Option < & ' a str > {
208
201
let suite_path = suite_path. as_ref ( ) ;
209
- let path = match path. strip_prefix ( "." ) {
210
- Ok ( p) => p,
211
- Err ( _) => path,
212
- } ;
202
+ let path = path. strip_prefix ( "." ) . unwrap_or ( path) ;
213
203
if !path. starts_with ( suite_path) {
214
204
return None ;
215
205
}
@@ -227,20 +217,15 @@ pub fn is_valid_test_suite_arg<'a, P: AsRef<Path>>(
227
217
// Therefore, we need to filter these out, as only the first --test-args
228
218
// flag is respected, so providing an empty --test-args conflicts with
229
219
// any following it.
230
- match path. strip_prefix ( suite_path) . ok ( ) . and_then ( |p| p. to_str ( ) ) {
231
- Some ( s) if !s. is_empty ( ) => Some ( s) ,
232
- _ => None ,
233
- }
220
+ path. strip_prefix ( suite_path) . ok ( ) . and_then ( |p| p. to_str ( ) ) . filter ( |s| !s. is_empty ( ) )
234
221
}
235
222
236
223
// FIXME: get rid of this function
237
224
pub fn check_run ( cmd : & mut BootstrapCommand , print_cmd_on_fail : bool ) -> bool {
238
- let status = match cmd. as_command_mut ( ) . status ( ) {
239
- Ok ( status) => status,
240
- Err ( e) => {
241
- println ! ( "failed to execute command: {cmd:?}\n ERROR: {e}" ) ;
242
- return false ;
243
- }
225
+ let Ok ( status) = cmd. as_command_mut ( ) . status ( ) . inspect_err ( |e| {
226
+ println ! ( "failed to execute command: {cmd:?}\n ERROR: {e}" ) ;
227
+ } ) else {
228
+ return false ;
244
229
} ;
245
230
if !status. success ( ) && print_cmd_on_fail {
246
231
println ! (
@@ -512,16 +497,15 @@ where
512
497
pub fn check_cfg_arg ( name : & str , values : Option < & [ & str ] > ) -> String {
513
498
// Creating a string of the values by concatenating each value:
514
499
// ',values("tvos","watchos")' or '' (nothing) when there are no values.
515
- let next = match values {
516
- Some ( values) => {
500
+ let next = values
501
+ . map ( | values| {
517
502
let mut tmp = values. iter ( ) . flat_map ( |val| [ "," , "\" " , val, "\" " ] ) . collect :: < String > ( ) ;
518
503
519
504
tmp. insert_str ( 1 , "values(" ) ;
520
505
tmp. push ( ')' ) ;
521
506
tmp
522
- }
523
- None => "" . to_string ( ) ,
524
- } ;
507
+ } )
508
+ . unwrap_or_default ( ) ;
525
509
format ! ( "--check-cfg=cfg({name}{next})" )
526
510
}
527
511
0 commit comments