diff options
| author | Philipp Oppermann <dev@phil-opp.com> | 2018-03-26 19:01:26 +0200 |
|---|---|---|
| committer | Philipp Oppermann <dev@phil-opp.com> | 2018-03-26 19:01:26 +0200 |
| commit | b889f98fba63dfcce68902c3a8c330fdea16a33b (patch) | |
| tree | 8ff62fb848d04b89fa9788725e3842889b93d9c1 | |
| parent | 7b49190d3cd98d9e3bc901993861f80269eb4155 (diff) | |
| download | rust-b889f98fba63dfcce68902c3a8c330fdea16a33b.tar.gz rust-b889f98fba63dfcce68902c3a8c330fdea16a33b.zip | |
Add a hash when a TargetPath is displayed
| -rw-r--r-- | src/librustc_back/target/mod.rs | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/src/librustc_back/target/mod.rs b/src/librustc_back/target/mod.rs index 3216aae8918..507243a58a5 100644 --- a/src/librustc_back/target/mod.rs +++ b/src/librustc_back/target/mod.rs @@ -1052,10 +1052,29 @@ impl TargetTriple { } } } + + /// Returns an extended string triple for this target. + /// + /// If this target is a path, a hash of the path is appended to the triple returned + /// by `triple()`. + pub fn debug_triple(&self) -> String { + use std::hash::{Hash, Hasher}; + use std::collections::hash_map::DefaultHasher; + + let triple = self.triple(); + if let &TargetTriple::TargetPath(ref path) = self { + let mut hasher = DefaultHasher::new(); + path.hash(&mut hasher); + let hash = hasher.finish(); + format!("{}-{}", triple, hash) + } else { + triple.to_owned() + } + } } impl fmt::Display for TargetTriple { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - write!(f, "{}", self.triple()) + write!(f, "{}", self.debug_triple()) } } |
