Skip to content

Commit 5f0b85a

Browse files
committed
don't change Display impl
1 parent 2bb79fb commit 5f0b85a

File tree

2 files changed

+20
-10
lines changed

2 files changed

+20
-10
lines changed

src/bootstrap/src/core/config/config.rs

+15-5
Original file line numberDiff line numberDiff line change
@@ -512,15 +512,19 @@ impl TargetSelection {
512512
pub fn is_windows(&self) -> bool {
513513
self.contains("windows")
514514
}
515-
}
516515

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+
}*/
520524
}
521525
}
522526

523-
impl fmt::Debug for TargetSelection {
527+
impl fmt::Display for TargetSelection {
524528
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
525529
write!(f, "{}", self.triple)?;
526530
if let Some(file) = self.file {
@@ -530,6 +534,12 @@ impl fmt::Debug for TargetSelection {
530534
}
531535
}
532536

537+
impl fmt::Debug for TargetSelection {
538+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
539+
write!(f, "{self}")
540+
}
541+
}
542+
533543
impl PartialEq<&str> for TargetSelection {
534544
fn eq(&self, other: &&str) -> bool {
535545
self.triple == *other

src/bootstrap/src/core/sanity.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use std::collections::HashMap;
1212
#[cfg(not(feature = "bootstrap-self-test"))]
1313
use std::collections::HashSet;
1414
use std::ffi::{OsStr, OsString};
15-
use std::path::{Path, PathBuf};
15+
use std::path::PathBuf;
1616
use std::{env, fs};
1717

1818
#[cfg(not(feature = "bootstrap-self-test"))]
@@ -259,18 +259,18 @@ than building it.
259259
has_target |= STAGE0_MISSING_TARGETS.contains(&target_str.as_str());
260260

261261
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()) {
264264
has_target = true;
265265
} else if let Some(custom_target_path) = env::var_os("RUST_TARGET_PATH") {
266266
let mut target_filename = OsString::from(&target_str);
267267
// Target filename ends with `.json`.
268268
target_filename.push(".json");
269-
269+
270270
// Recursively traverse through nested directories.
271271
let walker = walkdir::WalkDir::new(custom_target_path).into_iter();
272272
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;
274274
}
275275
}
276276
}

0 commit comments

Comments
 (0)