File tree 2 files changed +20
-10
lines changed
2 files changed +20
-10
lines changed Original file line number Diff line number Diff line change @@ -512,15 +512,19 @@ impl TargetSelection {
512
512
pub fn is_windows ( & self ) -> bool {
513
513
self . contains ( "windows" )
514
514
}
515
- }
516
515
517
- impl fmt:: Display for TargetSelection {
518
- fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
519
- if let Some ( file) = self . file { write ! ( f, "{file}" ) } else { write ! ( f, "{}" , self . triple) }
516
+ /// Path to the file defining the custom target, if any.
517
+ pub fn filepath ( & self ) -> Option < & Path > {
518
+ self . file . as_ref ( ) . map ( Path :: new)
519
+ /*if let Some(ref p) = self.file.as_ref {
520
+ Some(Path::new(p))
521
+ } else {
522
+ None
523
+ }*/
520
524
}
521
525
}
522
526
523
- impl fmt:: Debug for TargetSelection {
527
+ impl fmt:: Display for TargetSelection {
524
528
fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
525
529
write ! ( f, "{}" , self . triple) ?;
526
530
if let Some ( file) = self . file {
@@ -530,6 +534,12 @@ impl fmt::Debug for TargetSelection {
530
534
}
531
535
}
532
536
537
+ impl fmt:: Debug for TargetSelection {
538
+ fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
539
+ write ! ( f, "{self}" )
540
+ }
541
+ }
542
+
533
543
impl PartialEq < & str > for TargetSelection {
534
544
fn eq ( & self , other : & & str ) -> bool {
535
545
self . triple == * other
Original file line number Diff line number Diff line change @@ -12,7 +12,7 @@ use std::collections::HashMap;
12
12
#[ cfg( not( feature = "bootstrap-self-test" ) ) ]
13
13
use std:: collections:: HashSet ;
14
14
use std:: ffi:: { OsStr , OsString } ;
15
- use std:: path:: { Path , PathBuf } ;
15
+ use std:: path:: PathBuf ;
16
16
use std:: { env, fs} ;
17
17
18
18
#[ cfg( not( feature = "bootstrap-self-test" ) ) ]
@@ -259,18 +259,18 @@ than building it.
259
259
has_target |= STAGE0_MISSING_TARGETS . contains ( & target_str. as_str ( ) ) ;
260
260
261
261
if !has_target {
262
- // This might also be a custom target, so check the target file that could have been specified by the user.
263
- if Path :: new ( & target_str ) . exists ( ) {
262
+ // This might also be a custom target, so check the target file that could have been specified by the user.
263
+ if target . filepath ( ) . is_some_and ( |p| p . exists ( ) ) {
264
264
has_target = true ;
265
265
} else if let Some ( custom_target_path) = env:: var_os ( "RUST_TARGET_PATH" ) {
266
266
let mut target_filename = OsString :: from ( & target_str) ;
267
267
// Target filename ends with `.json`.
268
268
target_filename. push ( ".json" ) ;
269
-
269
+
270
270
// Recursively traverse through nested directories.
271
271
let walker = walkdir:: WalkDir :: new ( custom_target_path) . into_iter ( ) ;
272
272
for entry in walker. filter_map ( |e| e. ok ( ) ) {
273
- has_target |= entry. file_name ( ) == target_filename;
273
+ has_target |= entry. file_name ( ) == target_filename;
274
274
}
275
275
}
276
276
}
You can’t perform that action at this time.
0 commit comments