File tree 1 file changed +20
-1
lines changed
1 file changed +20
-1
lines changed Original file line number Diff line number Diff line change @@ -1052,10 +1052,29 @@ impl TargetTriple {
1052
1052
}
1053
1053
}
1054
1054
}
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
+ }
1055
1074
}
1056
1075
1057
1076
impl fmt:: Display for TargetTriple {
1058
1077
fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
1059
- write ! ( f, "{}" , self . triple ( ) )
1078
+ write ! ( f, "{}" , self . debug_triple ( ) )
1060
1079
}
1061
1080
}
You can’t perform that action at this time.
0 commit comments