diff --git a/src/errors.rs b/src/errors.rs index 2026a69..9cb1faa 100644 --- a/src/errors.rs +++ b/src/errors.rs @@ -1,6 +1,7 @@ use crate::prelude::*; use std::cell::RefCell; +use std::thread::panicking; use crate::{alloc::ArenaAllocator, typing::template::TemplateInput}; @@ -184,7 +185,7 @@ impl<'linker> ErrorCollector<'linker> { impl<'l> Drop for ErrorCollector<'l> { fn drop(&mut self) { - if !self.error_store.borrow().is_untouched() { + if !self.error_store.borrow().is_untouched() && !panicking() { panic!("ErrorCollector should have been emptied!"); } } diff --git a/src/typing/delayed_constraint.rs b/src/typing/delayed_constraint.rs index 95d7e32..5cedbd7 100644 --- a/src/typing/delayed_constraint.rs +++ b/src/typing/delayed_constraint.rs @@ -1,3 +1,5 @@ +use std::thread::panicking; + #[derive(Debug, Clone, Copy, PartialEq, Eq)] @@ -58,6 +60,8 @@ impl DelayedConstraintsList { impl Drop for DelayedConstraintsList { fn drop(&mut self) { - assert_eq!(self.0.len(), 0, "DelayedConstraintsList was not resolved."); + if !panicking() { + assert_eq!(self.0.len(), 0, "DelayedConstraintsList was not resolved."); + } } } diff --git a/src/typing/type_inference.rs b/src/typing/type_inference.rs index 374c428..ce999a6 100644 --- a/src/typing/type_inference.rs +++ b/src/typing/type_inference.rs @@ -4,6 +4,7 @@ use std::cell::{OnceCell, RefCell}; use std::fmt::Debug; use std::marker::PhantomData; use std::ops::{Deref, DerefMut, Index}; +use std::thread::panicking; use crate::block_vector::{BlockVec, BlockVecIter}; use crate::errors::ErrorInfo; @@ -166,7 +167,9 @@ impl+Clone, VariableIDMarker : UUIDMark impl, VariableIDMarker: UUIDMarker> Drop for TypeSubstitutor { fn drop(&mut self) { - assert!(self.failed_unifications.borrow().is_empty(), "Errors were not extracted before dropping!"); + if !panicking() { + assert!(self.failed_unifications.borrow().is_empty(), "Errors were not extracted before dropping!"); + } } }