diff options
| author | Camille GILLOT <gillot.camille@gmail.com> | 2020-03-14 17:37:34 +0100 |
|---|---|---|
| committer | Camille GILLOT <gillot.camille@gmail.com> | 2020-04-05 15:26:09 +0200 |
| commit | 81f0e90c62bda14f5e7279b3f771f69ac6bc153f (patch) | |
| tree | b46324424df8cd0d6b37b4dbb0c54c0c1e77095c | |
| parent | 5e1ad0d1e448a4ead87c52dd622e12a35c66a7f2 (diff) | |
| download | rust-81f0e90c62bda14f5e7279b3f771f69ac6bc153f.tar.gz rust-81f0e90c62bda14f5e7279b3f771f69ac6bc153f.zip | |
Remove unneeded Lrc in query results.
| -rw-r--r-- | src/librustc_metadata/rmeta/decoder.rs | 18 | ||||
| -rw-r--r-- | src/librustc_metadata/rmeta/decoder/cstore_impl.rs | 4 | ||||
| -rw-r--r-- | src/librustc_middle/arena.rs | 3 | ||||
| -rw-r--r-- | src/librustc_middle/query/mod.rs | 6 | ||||
| -rw-r--r-- | src/librustc_middle/ty/context.rs | 2 | ||||
| -rw-r--r-- | src/librustc_middle/ty/mod.rs | 2 | ||||
| -rw-r--r-- | src/librustc_passes/reachable.rs | 5 |
7 files changed, 21 insertions, 19 deletions
diff --git a/src/librustc_metadata/rmeta/decoder.rs b/src/librustc_metadata/rmeta/decoder.rs index 82b9b9693f3..786e6b3216f 100644 --- a/src/librustc_metadata/rmeta/decoder.rs +++ b/src/librustc_metadata/rmeta/decoder.rs @@ -1197,7 +1197,7 @@ impl<'a, 'tcx> CrateMetadataRef<'a> { } } - fn get_item_attrs(&self, node_id: DefIndex, sess: &Session) -> Lrc<[ast::Attribute]> { + fn get_item_attrs(&self, node_id: DefIndex, sess: &Session) -> Vec<ast::Attribute> { // The attributes for a tuple struct/variant are attached to the definition, not the ctor; // we assume that someone passing in a tuple struct ctor is actually wanting to // look at the definition @@ -1208,15 +1208,13 @@ impl<'a, 'tcx> CrateMetadataRef<'a> { node_id }; - Lrc::from( - self.root - .tables - .attributes - .get(self, item_id) - .unwrap_or(Lazy::empty()) - .decode((self, sess)) - .collect::<Vec<_>>(), - ) + self.root + .tables + .attributes + .get(self, item_id) + .unwrap_or(Lazy::empty()) + .decode((self, sess)) + .collect::<Vec<_>>() } fn get_struct_field_names(&self, id: DefIndex, sess: &Session) -> Vec<Spanned<ast::Name>> { diff --git a/src/librustc_metadata/rmeta/decoder/cstore_impl.rs b/src/librustc_metadata/rmeta/decoder/cstore_impl.rs index 1cbde23aceb..b36cd9b7ec6 100644 --- a/src/librustc_metadata/rmeta/decoder/cstore_impl.rs +++ b/src/librustc_metadata/rmeta/decoder/cstore_impl.rs @@ -138,7 +138,9 @@ provide! { <'tcx> tcx, def_id, other, cdata, lookup_deprecation_entry => { cdata.get_deprecation(def_id.index).map(DeprecationEntry::external) } - item_attrs => { cdata.get_item_attrs(def_id.index, tcx.sess) } + item_attrs => { tcx.arena.alloc_from_iter( + cdata.get_item_attrs(def_id.index, tcx.sess).into_iter() + ) } // FIXME(#38501) We've skipped a `read` on the `hir_owner_nodes` of // a `fn` when encoding, so the dep-tracking wouldn't work. // This is only used by rustdoc anyway, which shouldn't have diff --git a/src/librustc_middle/arena.rs b/src/librustc_middle/arena.rs index 979621d9240..9d64823d352 100644 --- a/src/librustc_middle/arena.rs +++ b/src/librustc_middle/arena.rs @@ -118,6 +118,9 @@ macro_rules! arena_types { [] upvars: rustc_data_structures::fx::FxIndexMap<rustc_hir::HirId, rustc_hir::Upvar>, [] object_safety_violations: rustc_middle::traits::ObjectSafetyViolation, [] codegen_unit: rustc_middle::mir::mono::CodegenUnit<$tcx>, + [] attribute: rustc_ast::ast::Attribute, + [] name_set: rustc_data_structures::fx::FxHashSet<rustc_ast::ast::Name>, + [] hir_id_set: rustc_hir::HirIdSet, // Interned types [] tys: rustc_middle::ty::TyS<$tcx>, diff --git a/src/librustc_middle/query/mod.rs b/src/librustc_middle/query/mod.rs index dc8834cf0ad..55ad94d70a5 100644 --- a/src/librustc_middle/query/mod.rs +++ b/src/librustc_middle/query/mod.rs @@ -610,7 +610,7 @@ rustc_queries! { } Other { - query reachable_set(_: CrateNum) -> Lrc<HirIdSet> { + query reachable_set(_: CrateNum) -> &'tcx HirIdSet { desc { "reachability" } } @@ -642,7 +642,7 @@ rustc_queries! { query lookup_stability(_: DefId) -> Option<&'tcx attr::Stability> {} query lookup_const_stability(_: DefId) -> Option<&'tcx attr::ConstStability> {} query lookup_deprecation_entry(_: DefId) -> Option<DeprecationEntry> {} - query item_attrs(_: DefId) -> Lrc<[ast::Attribute]> {} + query item_attrs(_: DefId) -> &'tcx [ast::Attribute] {} } Codegen { @@ -1047,7 +1047,7 @@ rustc_queries! { desc { "looking up all possibly unused extern crates" } } query names_imported_by_glob_use(_: DefId) - -> Lrc<FxHashSet<ast::Name>> { + -> &'tcx FxHashSet<ast::Name> { eval_always } diff --git a/src/librustc_middle/ty/context.rs b/src/librustc_middle/ty/context.rs index 95d0c758d08..7b177390f01 100644 --- a/src/librustc_middle/ty/context.rs +++ b/src/librustc_middle/ty/context.rs @@ -2721,7 +2721,7 @@ pub fn provide(providers: &mut ty::query::Providers<'_>) { }; providers.names_imported_by_glob_use = |tcx, id| { assert_eq!(id.krate, LOCAL_CRATE); - Lrc::new(tcx.glob_map.get(&id).cloned().unwrap_or_default()) + tcx.arena.alloc(tcx.glob_map.get(&id).cloned().unwrap_or_default()) }; providers.lookup_stability = |tcx, id| { diff --git a/src/librustc_middle/ty/mod.rs b/src/librustc_middle/ty/mod.rs index 9b182333907..5bd467f8793 100644 --- a/src/librustc_middle/ty/mod.rs +++ b/src/librustc_middle/ty/mod.rs @@ -3013,7 +3013,7 @@ impl<'tcx> TyCtxt<'tcx> { if let Some(id) = self.hir().as_local_hir_id(did) { Attributes::Borrowed(self.hir().attrs(id)) } else { - Attributes::Owned(self.item_attrs(did)) + Attributes::Borrowed(self.item_attrs(did)) } } diff --git a/src/librustc_passes/reachable.rs b/src/librustc_passes/reachable.rs index c0ae6519d2e..df947e15475 100644 --- a/src/librustc_passes/reachable.rs +++ b/src/librustc_passes/reachable.rs @@ -6,7 +6,6 @@ // reachable as well. use rustc_data_structures::fx::FxHashSet; -use rustc_data_structures::sync::Lrc; use rustc_hir as hir; use rustc_hir::def::{DefKind, Res}; use rustc_hir::def_id::LOCAL_CRATE; @@ -375,7 +374,7 @@ impl<'a, 'tcx> ItemLikeVisitor<'tcx> for CollectPrivateImplItemsVisitor<'a, 'tcx } } -fn reachable_set(tcx: TyCtxt<'_>, crate_num: CrateNum) -> Lrc<HirIdSet> { +fn reachable_set<'tcx>(tcx: TyCtxt<'tcx>, crate_num: CrateNum) -> &'tcx HirIdSet { debug_assert!(crate_num == LOCAL_CRATE); let access_levels = &tcx.privacy_access_levels(LOCAL_CRATE); @@ -421,7 +420,7 @@ fn reachable_set(tcx: TyCtxt<'_>, crate_num: CrateNum) -> Lrc<HirIdSet> { debug!("Inline reachability shows: {:?}", reachable_context.reachable_symbols); // Return the set of reachable symbols. - Lrc::new(reachable_context.reachable_symbols) + tcx.arena.alloc(reachable_context.reachable_symbols) } pub fn provide(providers: &mut Providers<'_>) { |
