From 0c2036883ab7c1525c8969be1b0a38d04ed96bf5 Mon Sep 17 00:00:00 2001 From: Tobias Tom Hodapp Date: Sun, 12 Jan 2025 00:55:27 +0100 Subject: [PATCH] Removed double panics from drop --- src/errors.rs | 3 ++- src/typing/delayed_constraint.rs | 6 +++++- src/typing/type_inference.rs | 5 ++++- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/errors.rs b/src/errors.rs index 042b013..4d8cc65 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}; @@ -178,7 +179,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!"); + } } }