feat(tvix/eval): improve panic!() messages in Thunk::value()

Change-Id: I3b1284e28c350bfed84d643ae7f922f3487e1f2a
Reviewed-on: https://cl.tvl.fyi/c/depot/+/7355
Autosubmit: Adam Joseph <adam@westernsemico.com>
Tested-by: BuildkiteCI
Reviewed-by: tazjin <tazjin@tvl.su>
This commit is contained in:
Adam Joseph 2022-11-21 22:56:45 -08:00 committed by clbot
parent de89dc9cfc
commit 4e33bc2390

View file

@ -144,8 +144,8 @@ impl Thunk {
// difficult to represent in the type system without impacting the
// API too much.
pub fn value(&self) -> Ref<Value> {
Ref::map(self.0.borrow(), |thunk| {
if let ThunkRepr::Evaluated(value) = thunk {
Ref::map(self.0.borrow(), |thunk| match thunk {
ThunkRepr::Evaluated(value) => {
#[cfg(debug_assertions)]
if matches!(
value,
@ -158,8 +158,8 @@ impl Thunk {
}
return value;
}
panic!("Thunk::value called on non-evaluated thunk");
ThunkRepr::Blackhole => panic!("Thunk::value called on a black-holed thunk"),
ThunkRepr::Suspended { .. } => panic!("Thunk::value called on a suspended thunk"),
})
}