From 4e33bc2390966d23580f64a60073452e20e67519 Mon Sep 17 00:00:00 2001 From: Adam Joseph Date: Mon, 21 Nov 2022 22:56:45 -0800 Subject: feat(tvix/eval): improve panic!() messages in Thunk::value() Change-Id: I3b1284e28c350bfed84d643ae7f922f3487e1f2a Reviewed-on: https://cl.tvl.fyi/c/depot/+/7355 Autosubmit: Adam Joseph Tested-by: BuildkiteCI Reviewed-by: tazjin --- tvix/eval/src/value/thunk.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'tvix/eval/src') diff --git a/tvix/eval/src/value/thunk.rs b/tvix/eval/src/value/thunk.rs index 5eee07a9e7..5107c6328d 100644 --- a/tvix/eval/src/value/thunk.rs +++ b/tvix/eval/src/value/thunk.rs @@ -144,8 +144,8 @@ impl Thunk { // difficult to represent in the type system without impacting the // API too much. pub fn value(&self) -> Ref { - 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"), }) } -- cgit 1.4.1