diff options
| author | Oli Scherer <git-spam-no-reply9815368754983@oli-obk.de> | 2022-12-08 11:02:47 +0000 |
|---|---|---|
| committer | Oli Scherer <git-spam-no-reply9815368754983@oli-obk.de> | 2023-02-20 15:28:58 +0000 |
| commit | 6924e3c374563217a724f7ffca1a5087166e8f49 (patch) | |
| tree | 409ef2c141665701623473ddea7fb4b14dfdf255 | |
| parent | ade3dceb38c6e41e3b8623e252d9413052e3a0af (diff) | |
| download | rust-6924e3c374563217a724f7ffca1a5087166e8f49.tar.gz rust-6924e3c374563217a724f7ffca1a5087166e8f49.zip | |
Make untracked.source_span lockable so that resolution can still write to it when using TyCtxt
| -rw-r--r-- | compiler/rustc_middle/src/ty/context.rs | 4 | ||||
| -rw-r--r-- | compiler/rustc_query_system/src/ich/hcx.rs | 2 | ||||
| -rw-r--r-- | compiler/rustc_resolve/src/diagnostics.rs | 6 | ||||
| -rw-r--r-- | compiler/rustc_resolve/src/imports.rs | 4 | ||||
| -rw-r--r-- | compiler/rustc_resolve/src/lib.rs | 6 | ||||
| -rw-r--r-- | compiler/rustc_session/src/cstore.rs | 2 |
6 files changed, 12 insertions, 12 deletions
diff --git a/compiler/rustc_middle/src/ty/context.rs b/compiler/rustc_middle/src/ty/context.rs index 335d568bf31..5fcbf87a982 100644 --- a/compiler/rustc_middle/src/ty/context.rs +++ b/compiler/rustc_middle/src/ty/context.rs @@ -1026,7 +1026,7 @@ impl<'tcx> TyCtxt<'tcx> { /// system if the result is otherwise tracked through queries #[inline] pub fn source_span_untracked(self, def_id: LocalDefId) -> Span { - self.untracked.source_span.get(def_id).copied().unwrap_or(DUMMY_SP) + self.untracked.source_span.read().get(def_id).copied().unwrap_or(DUMMY_SP) } #[inline(always)] @@ -2518,5 +2518,5 @@ pub fn provide(providers: &mut ty::query::Providers) { tcx.lang_items().panic_impl().map_or(false, |did| did.is_local()) }; providers.source_span = - |tcx, def_id| tcx.untracked.source_span.get(def_id).copied().unwrap_or(DUMMY_SP); + |tcx, def_id| tcx.untracked.source_span.read().get(def_id).copied().unwrap_or(DUMMY_SP); } diff --git a/compiler/rustc_query_system/src/ich/hcx.rs b/compiler/rustc_query_system/src/ich/hcx.rs index 91fc3fd222f..8db8ee9428b 100644 --- a/compiler/rustc_query_system/src/ich/hcx.rs +++ b/compiler/rustc_query_system/src/ich/hcx.rs @@ -146,7 +146,7 @@ impl<'a> rustc_span::HashStableContext for StableHashingContext<'a> { #[inline] fn def_span(&self, def_id: LocalDefId) -> Span { - *self.untracked.source_span.get(def_id).unwrap_or(&DUMMY_SP) + *self.untracked.source_span.read().get(def_id).unwrap_or(&DUMMY_SP) } #[inline] diff --git a/compiler/rustc_resolve/src/diagnostics.rs b/compiler/rustc_resolve/src/diagnostics.rs index 80c21bb0830..6bb6e92da9e 100644 --- a/compiler/rustc_resolve/src/diagnostics.rs +++ b/compiler/rustc_resolve/src/diagnostics.rs @@ -155,7 +155,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { if !candidates.is_empty() { show_candidates( &self.tcx.sess, - &self.untracked.source_span, + &self.untracked.source_span.read(), &mut err, span, &candidates, @@ -688,7 +688,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { } show_candidates( &self.tcx.sess, - &self.untracked.source_span, + &self.untracked.source_span.read(), &mut err, Some(span), &import_suggestions, @@ -1353,7 +1353,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { self.lookup_import_candidates(ident, Namespace::MacroNS, parent_scope, is_expected); show_candidates( &self.tcx.sess, - &self.untracked.source_span, + &self.untracked.source_span.read(), err, None, &import_suggestions, diff --git a/compiler/rustc_resolve/src/imports.rs b/compiler/rustc_resolve/src/imports.rs index 0862e56a4c4..6171dd657bf 100644 --- a/compiler/rustc_resolve/src/imports.rs +++ b/compiler/rustc_resolve/src/imports.rs @@ -549,7 +549,7 @@ impl<'a, 'b, 'tcx> ImportResolver<'a, 'b, 'tcx> { match &import.kind { ImportKind::Single { nested: false, source, target, .. } => import_candidates( self.r.tcx.sess, - &self.r.untracked.source_span, + &self.r.untracked.source_span.read(), &mut diag, Some(err.span), &candidates, @@ -562,7 +562,7 @@ impl<'a, 'b, 'tcx> ImportResolver<'a, 'b, 'tcx> { ImportKind::Single { nested: true, source, target, .. } => { import_candidates( self.r.tcx.sess, - &self.r.untracked.source_span, + &self.r.untracked.source_span.read(), &mut diag, None, &candidates, diff --git a/compiler/rustc_resolve/src/lib.rs b/compiler/rustc_resolve/src/lib.rs index afadc0b2a0c..7a8e594a8f9 100644 --- a/compiler/rustc_resolve/src/lib.rs +++ b/compiler/rustc_resolve/src/lib.rs @@ -1180,7 +1180,7 @@ impl<'tcx> Resolver<'_, 'tcx> { // A relative span's parent must be an absolute span. debug_assert_eq!(span.data_untracked().parent, None); - let _id = self.untracked.source_span.push(span); + let _id = self.untracked.source_span.write().push(span); debug_assert_eq!(_id, def_id); // Some things for which we allocate `LocalDefId`s don't correspond to @@ -1329,7 +1329,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { used_extern_options: Default::default(), untracked: Untracked { cstore: RwLock::new(Box::new(CStore::new(session))), - source_span, + source_span: RwLock::new(source_span), definitions: RwLock::new(definitions), }, macro_names: FxHashSet::default(), @@ -1932,7 +1932,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { /// Retrieves the span of the given `DefId` if `DefId` is in the local crate. #[inline] fn opt_span(&self, def_id: DefId) -> Option<Span> { - def_id.as_local().map(|def_id| self.untracked.source_span[def_id]) + def_id.as_local().map(|def_id| self.untracked.source_span.read()[def_id]) } /// Retrieves the name of the given `DefId`. diff --git a/compiler/rustc_session/src/cstore.rs b/compiler/rustc_session/src/cstore.rs index ef82bb23360..796ceba7ad3 100644 --- a/compiler/rustc_session/src/cstore.rs +++ b/compiler/rustc_session/src/cstore.rs @@ -256,6 +256,6 @@ pub type CrateStoreDyn = dyn CrateStore + sync::Sync + sync::Send; pub struct Untracked { pub cstore: RwLock<Box<CrateStoreDyn>>, /// Reference span for definitions. - pub source_span: IndexVec<LocalDefId, Span>, + pub source_span: RwLock<IndexVec<LocalDefId, Span>>, pub definitions: RwLock<Definitions>, } |
