File tree Expand file tree Collapse file tree 1 file changed +20
-1
lines changed Expand file tree Collapse file tree 1 file changed +20
-1
lines changed Original file line number Diff line number Diff 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
10571076impl 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}
You can’t perform that action at this time.
0 commit comments