@@ -88,7 +88,7 @@ impl SessionGlobals {
8888}
8989
9090pub fn with_session_globals < R > ( edition : Edition , f : impl FnOnce ( ) -> R ) -> R {
91- let session_globals = SessionGlobals :: new ( edition) ;
91+ let session_globals = Lrc :: new ( SessionGlobals :: new ( edition) ) ;
9292 SESSION_GLOBALS . set ( & session_globals, f)
9393}
9494
@@ -99,7 +99,7 @@ pub fn with_default_session_globals<R>(f: impl FnOnce() -> R) -> R {
9999// If this ever becomes non thread-local, `decode_syntax_context`
100100// and `decode_expn_id` will need to be updated to handle concurrent
101101// deserialization.
102- scoped_tls:: scoped_thread_local!( pub static SESSION_GLOBALS : SessionGlobals ) ;
102+ scoped_tls:: scoped_thread_local!( pub static SESSION_GLOBALS : Lrc < SessionGlobals > ) ;
103103
104104// FIXME: Perhaps this should not implement Rustc{Decodable, Encodable}
105105//
@@ -1746,6 +1746,7 @@ fn lookup_line(lines: &[BytePos], pos: BytePos) -> isize {
17461746/// This is a hack to allow using the `HashStable_Generic` derive macro
17471747/// instead of implementing everything in librustc_middle.
17481748pub trait HashStableContext {
1749+ fn session_globals ( & self ) -> & SessionGlobals ;
17491750 fn hash_def_id ( & mut self , _: DefId , hasher : & mut StableHasher ) ;
17501751 fn hash_crate_num ( & mut self , _: CrateNum , hasher : & mut StableHasher ) ;
17511752 fn hash_spans ( & self ) -> bool ;
@@ -1781,10 +1782,12 @@ where
17811782 return ;
17821783 }
17831784
1785+ let globals = ctx. session_globals ( ) ;
1786+
17841787 // If this is not an empty or invalid span, we want to hash the last
17851788 // position that belongs to it, as opposed to hashing the first
17861789 // position past it.
1787- let span = self . data ( ) ;
1790+ let span = self . data_from_globals ( globals ) ;
17881791 let ( file_lo, line_lo, col_lo) = match ctx. byte_pos_to_line_and_col ( span. lo ) {
17891792 Some ( pos) => pos,
17901793 None => {
0 commit comments