Skip to content

Commit

Permalink
Explain Interns::key_get Key Debug sensitivity.
Browse files Browse the repository at this point in the history
This follows up on pantsbuild#12152.

# Building wheels and fs_util will be skipped. Delete if not intended.
[ci skip-build-wheels]
  • Loading branch information
jsirois committed Jun 2, 2021
1 parent a59be85 commit 09ed6df
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/rust/engine/src/interning.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,14 @@ impl Interns {
.get(&k)
.cloned()
.unwrap_or_else(|| {
// N.B.: This panic is effectively an assertion that `Key::new` is only ever called above in
// `key_insert` under an exclusive lock where it is then inserted in `reverse_keys` before
// exiting the lock and being returned to the caller. This ensures that all `Key`s in the
// wild _must_ be in `reverse_keys`. As such, the code involved in generating the panic
// message should be immaterial and never fire. If it does fire though, then the assertion
// was proven incorrect and the `Key` is not, in fact, in `reverse_keys`. Since the `Debug`
// impl for `Key` currently uses this very method to render the `Key` we avoid using the
// debug formatting for `Key` to avoid generating a panic while panicking.
panic!(
"Previously memoized object disappeared for Key {{ id: {}, type_id: {} }}!",
k.id(),
Expand Down

0 comments on commit 09ed6df

Please sign in to comment.