File tree Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -28,6 +28,8 @@ pub struct Rustc {
2828 pub version : semver:: Version ,
2929 /// The host triple (arch-platform-OS), this comes from verbose_version.
3030 pub host : InternedString ,
31+ /// The rustc full commit hash, this comes from `verbose_version`.
32+ pub commit_hash : String ,
3133 cache : Mutex < Cache > ,
3234}
3335
@@ -80,6 +82,18 @@ impl Rustc {
8082 verbose_version
8183 )
8284 } ) ?;
85+ let commit_hash = {
86+ let hash = extract ( "commit-hash: " ) ?;
87+ assert ! (
88+ hash. chars( ) . all( |ch| ch. is_ascii_hexdigit( ) ) ,
89+ "commit hash must be a hex string"
90+ ) ;
91+ assert ! (
92+ hash. len( ) == 40 || hash. len( ) == 64 ,
93+ "hex string must be generated from sha1 or sha256"
94+ ) ;
95+ hash. to_string ( )
96+ } ;
8397
8498 Ok ( Rustc {
8599 path,
@@ -88,6 +102,7 @@ impl Rustc {
88102 verbose_version,
89103 version,
90104 host,
105+ commit_hash,
91106 cache : Mutex :: new ( cache) ,
92107 } )
93108 }
You can’t perform that action at this time.
0 commit comments