Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 81f0e90

Browse files
committed
Remove unneeded Lrc in query results.
1 parent 5e1ad0d commit 81f0e90

File tree

7 files changed

+21
-19
lines changed

7 files changed

+21
-19
lines changed

src/librustc_metadata/rmeta/decoder.rs

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1197,7 +1197,7 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
11971197
}
11981198
}
11991199

1200-
fn get_item_attrs(&self, node_id: DefIndex, sess: &Session) -> Lrc<[ast::Attribute]> {
1200+
fn get_item_attrs(&self, node_id: DefIndex, sess: &Session) -> Vec<ast::Attribute> {
12011201
// The attributes for a tuple struct/variant are attached to the definition, not the ctor;
12021202
// we assume that someone passing in a tuple struct ctor is actually wanting to
12031203
// look at the definition
@@ -1208,15 +1208,13 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
12081208
node_id
12091209
};
12101210

1211-
Lrc::from(
1212-
self.root
1213-
.tables
1214-
.attributes
1215-
.get(self, item_id)
1216-
.unwrap_or(Lazy::empty())
1217-
.decode((self, sess))
1218-
.collect::<Vec<_>>(),
1219-
)
1211+
self.root
1212+
.tables
1213+
.attributes
1214+
.get(self, item_id)
1215+
.unwrap_or(Lazy::empty())
1216+
.decode((self, sess))
1217+
.collect::<Vec<_>>()
12201218
}
12211219

12221220
fn get_struct_field_names(&self, id: DefIndex, sess: &Session) -> Vec<Spanned<ast::Name>> {

src/librustc_metadata/rmeta/decoder/cstore_impl.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,9 @@ provide! { <'tcx> tcx, def_id, other, cdata,
138138
lookup_deprecation_entry => {
139139
cdata.get_deprecation(def_id.index).map(DeprecationEntry::external)
140140
}
141-
item_attrs => { cdata.get_item_attrs(def_id.index, tcx.sess) }
141+
item_attrs => { tcx.arena.alloc_from_iter(
142+
cdata.get_item_attrs(def_id.index, tcx.sess).into_iter()
143+
) }
142144
// FIXME(#38501) We've skipped a `read` on the `hir_owner_nodes` of
143145
// a `fn` when encoding, so the dep-tracking wouldn't work.
144146
// This is only used by rustdoc anyway, which shouldn't have

src/librustc_middle/arena.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,9 @@ macro_rules! arena_types {
118118
[] upvars: rustc_data_structures::fx::FxIndexMap<rustc_hir::HirId, rustc_hir::Upvar>,
119119
[] object_safety_violations: rustc_middle::traits::ObjectSafetyViolation,
120120
[] codegen_unit: rustc_middle::mir::mono::CodegenUnit<$tcx>,
121+
[] attribute: rustc_ast::ast::Attribute,
122+
[] name_set: rustc_data_structures::fx::FxHashSet<rustc_ast::ast::Name>,
123+
[] hir_id_set: rustc_hir::HirIdSet,
121124

122125
// Interned types
123126
[] tys: rustc_middle::ty::TyS<$tcx>,

src/librustc_middle/query/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -610,7 +610,7 @@ rustc_queries! {
610610
}
611611

612612
Other {
613-
query reachable_set(_: CrateNum) -> Lrc<HirIdSet> {
613+
query reachable_set(_: CrateNum) -> &'tcx HirIdSet {
614614
desc { "reachability" }
615615
}
616616

@@ -642,7 +642,7 @@ rustc_queries! {
642642
query lookup_stability(_: DefId) -> Option<&'tcx attr::Stability> {}
643643
query lookup_const_stability(_: DefId) -> Option<&'tcx attr::ConstStability> {}
644644
query lookup_deprecation_entry(_: DefId) -> Option<DeprecationEntry> {}
645-
query item_attrs(_: DefId) -> Lrc<[ast::Attribute]> {}
645+
query item_attrs(_: DefId) -> &'tcx [ast::Attribute] {}
646646
}
647647

648648
Codegen {
@@ -1047,7 +1047,7 @@ rustc_queries! {
10471047
desc { "looking up all possibly unused extern crates" }
10481048
}
10491049
query names_imported_by_glob_use(_: DefId)
1050-
-> Lrc<FxHashSet<ast::Name>> {
1050+
-> &'tcx FxHashSet<ast::Name> {
10511051
eval_always
10521052
}
10531053

src/librustc_middle/ty/context.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2721,7 +2721,7 @@ pub fn provide(providers: &mut ty::query::Providers<'_>) {
27212721
};
27222722
providers.names_imported_by_glob_use = |tcx, id| {
27232723
assert_eq!(id.krate, LOCAL_CRATE);
2724-
Lrc::new(tcx.glob_map.get(&id).cloned().unwrap_or_default())
2724+
tcx.arena.alloc(tcx.glob_map.get(&id).cloned().unwrap_or_default())
27252725
};
27262726

27272727
providers.lookup_stability = |tcx, id| {

src/librustc_middle/ty/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3013,7 +3013,7 @@ impl<'tcx> TyCtxt<'tcx> {
30133013
if let Some(id) = self.hir().as_local_hir_id(did) {
30143014
Attributes::Borrowed(self.hir().attrs(id))
30153015
} else {
3016-
Attributes::Owned(self.item_attrs(did))
3016+
Attributes::Borrowed(self.item_attrs(did))
30173017
}
30183018
}
30193019

src/librustc_passes/reachable.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
// reachable as well.
77

88
use rustc_data_structures::fx::FxHashSet;
9-
use rustc_data_structures::sync::Lrc;
109
use rustc_hir as hir;
1110
use rustc_hir::def::{DefKind, Res};
1211
use rustc_hir::def_id::LOCAL_CRATE;
@@ -375,7 +374,7 @@ impl<'a, 'tcx> ItemLikeVisitor<'tcx> for CollectPrivateImplItemsVisitor<'a, 'tcx
375374
}
376375
}
377376

378-
fn reachable_set(tcx: TyCtxt<'_>, crate_num: CrateNum) -> Lrc<HirIdSet> {
377+
fn reachable_set<'tcx>(tcx: TyCtxt<'tcx>, crate_num: CrateNum) -> &'tcx HirIdSet {
379378
debug_assert!(crate_num == LOCAL_CRATE);
380379

381380
let access_levels = &tcx.privacy_access_levels(LOCAL_CRATE);
@@ -421,7 +420,7 @@ fn reachable_set(tcx: TyCtxt<'_>, crate_num: CrateNum) -> Lrc<HirIdSet> {
421420
debug!("Inline reachability shows: {:?}", reachable_context.reachable_symbols);
422421

423422
// Return the set of reachable symbols.
424-
Lrc::new(reachable_context.reachable_symbols)
423+
tcx.arena.alloc(reachable_context.reachable_symbols)
425424
}
426425

427426
pub fn provide(providers: &mut Providers<'_>) {

0 commit comments

Comments
 (0)