Ensure ImplicitCtxt is Sync

This commit is contained in:
John Kåre Alsaker 2018-04-26 01:03:54 +02:00
parent 9eb4f7329b
commit 85acb1d046

View File

@ -1704,7 +1704,7 @@ pub mod tls {
use ty::maps;
use errors::{Diagnostic, TRACK_DIAGNOSTICS};
use rustc_data_structures::OnDrop;
use rustc_data_structures::sync::Lrc;
use rustc_data_structures::sync::{self, Lrc};
use dep_graph::OpenTask;
/// This is the implicit state of rustc. It contains the current
@ -1832,6 +1832,10 @@ pub fn with_context_opt<F, R>(f: F) -> R
if context == 0 {
f(None)
} else {
// We could get a ImplicitCtxt pointer from another thread.
// Ensure that ImplicitCtxt is Sync
sync::assert_sync::<ImplicitCtxt>();
unsafe { f(Some(&*(context as *const ImplicitCtxt))) }
}
}