Skip to content

Commit

Permalink
avoid double panic
Browse files Browse the repository at this point in the history
  • Loading branch information
nikomatsakis committed May 2, 2016
1 parent 9d151a7 commit db8a9a9
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/libsyntax/errors/mod.rs
Expand Up @@ -20,6 +20,7 @@ use errors::emitter::{Emitter, EmitterWriter};
use std::cell::{RefCell, Cell};
use std::{error, fmt};
use std::rc::Rc;
use std::thread::panicking;
use term;

pub mod emitter;
Expand Down Expand Up @@ -352,7 +353,7 @@ impl<'a> fmt::Debug for DiagnosticBuilder<'a> {
/// we emit a bug.
impl<'a> Drop for DiagnosticBuilder<'a> {
fn drop(&mut self) {
if !self.cancelled() {
if !panicking() && !self.cancelled() {
self.emitter.borrow_mut().emit(&MultiSpan::new(),
"Error constructed but not emitted",
None,
Expand Down

0 comments on commit db8a9a9

Please sign in to comment.