From 81f0e90c62bda14f5e7279b3f771f69ac6bc153f Mon Sep 17 00:00:00 2001 From: Camille GILLOT Date: Sat, 14 Mar 2020 17:37:34 +0100 Subject: [PATCH] Remove unneeded Lrc in query results. --- src/librustc_metadata/rmeta/decoder.rs | 18 ++++++++---------- .../rmeta/decoder/cstore_impl.rs | 4 +++- src/librustc_middle/arena.rs | 3 +++ src/librustc_middle/query/mod.rs | 6 +++--- src/librustc_middle/ty/context.rs | 2 +- src/librustc_middle/ty/mod.rs | 2 +- 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 @@ fn get_ctor_def_id(&self, node_id: DefIndex) -> Option { } } - fn get_item_attrs(&self, node_id: DefIndex, sess: &Session) -> Lrc<[ast::Attribute]> { + fn get_item_attrs(&self, node_id: DefIndex, sess: &Session) -> Vec { // 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 @@ fn get_item_attrs(&self, node_id: DefIndex, sess: &Session) -> Lrc<[ast::Attribu node_id }; - Lrc::from( - self.root - .tables - .attributes - .get(self, item_id) - .unwrap_or(Lazy::empty()) - .decode((self, sess)) - .collect::>(), - ) + self.root + .tables + .attributes + .get(self, item_id) + .unwrap_or(Lazy::empty()) + .decode((self, sess)) + .collect::>() } fn get_struct_field_names(&self, id: DefIndex, sess: &Session) -> Vec> { 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 @@ fn into_args(self) -> (DefId, DefId) { 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, [] 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, + [] 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 @@ fn describe_as_module(def_id: DefId, tcx: TyCtxt<'_>) -> String { } Other { - query reachable_set(_: CrateNum) -> Lrc { + query reachable_set(_: CrateNum) -> &'tcx HirIdSet { desc { "reachability" } } @@ -642,7 +642,7 @@ fn describe_as_module(def_id: DefId, tcx: TyCtxt<'_>) -> String { query lookup_stability(_: DefId) -> Option<&'tcx attr::Stability> {} query lookup_const_stability(_: DefId) -> Option<&'tcx attr::ConstStability> {} query lookup_deprecation_entry(_: DefId) -> Option {} - query item_attrs(_: DefId) -> Lrc<[ast::Attribute]> {} + query item_attrs(_: DefId) -> &'tcx [ast::Attribute] {} } Codegen { @@ -1047,7 +1047,7 @@ fn describe_as_module(def_id: DefId, tcx: TyCtxt<'_>) -> String { desc { "looking up all possibly unused extern crates" } } query names_imported_by_glob_use(_: DefId) - -> Lrc> { + -> &'tcx FxHashSet { 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 @@ pub fn get_attrs(self, did: DefId) -> Attributes<'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 @@ fn visit_impl_item(&mut self, _impl_item: &hir::ImplItem<'_>) { } } -fn reachable_set(tcx: TyCtxt<'_>, crate_num: CrateNum) -> Lrc { +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 { 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<'_>) { -- 2.44.0