Skip to content

Commit fdbf2c8

Browse files
committed
Fix safety hole
1 parent ec3e182 commit fdbf2c8

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/librustc/ty/context.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -1754,7 +1754,7 @@ pub mod tls {
17541754
use rustc_data_structures::OnDrop;
17551755
use rayon_core;
17561756
use dep_graph::OpenTask;
1757-
use rustc_data_structures::sync::{Lrc, Lock};
1757+
use rustc_data_structures::sync::{self, Lrc, Lock};
17581758

17591759
/// This is the implicit state of rustc. It contains the current
17601760
/// TyCtxt and query. It is updated when creating a local interner or
@@ -1924,6 +1924,10 @@ pub mod tls {
19241924
if context == 0 {
19251925
f(None)
19261926
} else {
1927+
// We could get a ImplicitCtxt pointer from another thread.
1928+
// Ensure that ImplicitCtxt is Sync
1929+
sync::assert_sync::<ImplicitCtxt>();
1930+
19271931
unsafe { f(Some(&*(context as *const ImplicitCtxt))) }
19281932
}
19291933
}

0 commit comments

Comments
 (0)