Skip to content

Commit

Permalink
Auto merge of #12963 - RalfJung:commit-hash, r=weihanglo
Browse files Browse the repository at this point in the history
make some debug assertion failures more informative

In rust-lang/miri#3160, we got a report of a user running into an assertion failure in cargo. Unfortunately the failure message is not very informative. This PR hopefully makes that failure easier to debug.
  • Loading branch information
bors committed Nov 12, 2023
2 parents 3eb246c + 1b3a53c commit fa62a0e
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/cargo/util/rustc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,11 @@ impl Rustc {
let commit_hash = extract("commit-hash: ").ok().map(|hash| {
debug_assert!(
hash.chars().all(|ch| ch.is_ascii_hexdigit()),
"commit hash must be a hex string"
"commit hash must be a hex string, got: {hash:?}"
);
debug_assert!(
hash.len() == 40 || hash.len() == 64,
"hex string must be generated from sha1 or sha256"
"hex string must be generated from sha1 or sha256 (i.e., it must be 40 or 64 characters long)\ngot: {hash:?}"
);
hash.to_string()
});
Expand Down

0 comments on commit fa62a0e

Please sign in to comment.