Skip to content

Commit b889f98

Browse files
committed
Add a hash when a TargetPath is displayed
1 parent 7b49190 commit b889f98

File tree

1 file changed

+20
-1
lines changed
  • src/librustc_back/target

1 file changed

+20
-1
lines changed

Diff for: src/librustc_back/target/mod.rs

+20-1
Original file line numberDiff line numberDiff line change
@@ -1052,10 +1052,29 @@ impl TargetTriple {
10521052
}
10531053
}
10541054
}
1055+
1056+
/// Returns an extended string triple for this target.
1057+
///
1058+
/// If this target is a path, a hash of the path is appended to the triple returned
1059+
/// by `triple()`.
1060+
pub fn debug_triple(&self) -> String {
1061+
use std::hash::{Hash, Hasher};
1062+
use std::collections::hash_map::DefaultHasher;
1063+
1064+
let triple = self.triple();
1065+
if let &TargetTriple::TargetPath(ref path) = self {
1066+
let mut hasher = DefaultHasher::new();
1067+
path.hash(&mut hasher);
1068+
let hash = hasher.finish();
1069+
format!("{}-{}", triple, hash)
1070+
} else {
1071+
triple.to_owned()
1072+
}
1073+
}
10551074
}
10561075

10571076
impl fmt::Display for TargetTriple {
10581077
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
1059-
write!(f, "{}", self.triple())
1078+
write!(f, "{}", self.debug_triple())
10601079
}
10611080
}

0 commit comments

Comments
 (0)