Drop impl should only panic if not already panicking

This commit is contained in:
David Tolnay 2018-03-13 09:42:07 -07:00
parent 69dd3215f4
commit 5bc805329e
No known key found for this signature in database
GPG Key ID: F9BA143B95FF6D82

View File

@ -8,6 +8,7 @@
use std::fmt::Display; use std::fmt::Display;
use std::cell::RefCell; use std::cell::RefCell;
use std::thread;
#[derive(Default)] #[derive(Default)]
pub struct Ctxt { pub struct Ctxt {
@ -48,7 +49,7 @@ impl Ctxt {
impl Drop for Ctxt { impl Drop for Ctxt {
fn drop(&mut self) { fn drop(&mut self) {
if self.errors.borrow().is_some() { if !thread::panicking() && self.errors.borrow().is_some() {
panic!("forgot to check for errors"); panic!("forgot to check for errors");
} }
} }