From 03b7cec2defdec00bef79045252341dd49fc9f0c Mon Sep 17 00:00:00 2001 From: John Kåre Alsaker Date: Wed, 5 Dec 2018 16:51:58 +0100 Subject: Replace LockCell with atomic types --- src/librustc_errors/lib.rs | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'src/librustc_errors') diff --git a/src/librustc_errors/lib.rs b/src/librustc_errors/lib.rs index f0fde6bbd8e..a074441f8a1 100644 --- a/src/librustc_errors/lib.rs +++ b/src/librustc_errors/lib.rs @@ -26,15 +26,13 @@ use self::Level::*; use emitter::{Emitter, EmitterWriter}; -use rustc_data_structures::sync::{self, Lrc, Lock, LockCell}; +use rustc_data_structures::sync::{self, Lrc, Lock, AtomicUsize, AtomicBool, SeqCst}; use rustc_data_structures::fx::FxHashSet; use rustc_data_structures::stable_hasher::StableHasher; use std::borrow::Cow; use std::cell::Cell; use std::{error, fmt}; -use std::sync::atomic::AtomicUsize; -use std::sync::atomic::Ordering::SeqCst; use std::panic; use termcolor::{ColorSpec, Color}; @@ -271,7 +269,7 @@ pub struct Handler { err_count: AtomicUsize, emitter: Lock>, - continue_after_error: LockCell, + continue_after_error: AtomicBool, delayed_span_bugs: Lock>, // This set contains the `DiagnosticId` of all emitted diagnostics to avoid @@ -370,7 +368,7 @@ impl Handler { flags, err_count: AtomicUsize::new(0), emitter: Lock::new(e), - continue_after_error: LockCell::new(true), + continue_after_error: AtomicBool::new(true), delayed_span_bugs: Lock::new(Vec::new()), taught_diagnostics: Default::default(), emitted_diagnostic_codes: Default::default(), @@ -379,7 +377,7 @@ impl Handler { } pub fn set_continue_after_error(&self, continue_after_error: bool) { - self.continue_after_error.set(continue_after_error); + self.continue_after_error.store(continue_after_error, SeqCst); } /// Resets the diagnostic error count as well as the cached emitted diagnostics. @@ -658,7 +656,7 @@ impl Handler { let mut db = DiagnosticBuilder::new(self, lvl, msg); db.set_span(msp.clone()); db.emit(); - if !self.continue_after_error.get() { + if !self.continue_after_error.load(SeqCst) { self.abort_if_errors(); } } @@ -669,7 +667,7 @@ impl Handler { let mut db = DiagnosticBuilder::new_with_code(self, lvl, Some(code), msg); db.set_span(msp.clone()); db.emit(); - if !self.continue_after_error.get() { + if !self.continue_after_error.load(SeqCst) { self.abort_if_errors(); } } -- cgit 1.4.1-3-g733a5