Skip to content

Commit e333277

Browse files
committed
Move a few queries to using an arena.
1 parent 0b78983 commit e333277

File tree

6 files changed

+17
-13
lines changed

6 files changed

+17
-13
lines changed

src/librustc_codegen_llvm/attributes.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ pub fn from_fn_attrs(cx: &CodegenCx<'ll, 'tcx>, llfn: &'ll Value, instance: ty::
252252
inline(cx, llfn, attributes::InlineAttr::Hint);
253253
}
254254

255-
inline(cx, llfn, codegen_fn_attrs.inline);
255+
inline(cx, llfn, codegen_fn_attrs.inline.clone());
256256

257257
// The `uwtable` attribute according to LLVM is:
258258
//

src/librustc_middle/query/mod.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -367,10 +367,12 @@ rustc_queries! {
367367
query associated_item_def_ids(_: DefId) -> &'tcx [DefId] {}
368368

369369
/// Maps from a trait item to the trait item "descriptor".
370-
query associated_item(_: DefId) -> ty::AssocItem {}
370+
query associated_item(_: DefId) -> ty::AssocItem {
371+
storage(ArenaCacheSelector<'tcx>)
372+
}
371373

372374
/// Collects the associated items defined on a trait or impl.
373-
query associated_items(key: DefId) -> ty::AssociatedItems {
375+
query associated_items(key: DefId) -> ty::AssociatedItems<'tcx> {
374376
storage(ArenaCacheSelector<'tcx>)
375377
desc { |tcx| "collecting associated items of {}", tcx.def_path_str(key) }
376378
}
@@ -395,6 +397,7 @@ rustc_queries! {
395397
query unsafety_check_result(key: LocalDefId) -> mir::UnsafetyCheckResult {
396398
desc { |tcx| "unsafety-checking `{}`", tcx.def_path_str(key.to_def_id()) }
397399
cache_on_disk_if { true }
400+
storage(ArenaCacheSelector<'tcx>)
398401
}
399402

400403
/// HACK: when evaluated, this reports a "unsafe derive on repr(packed)" error
@@ -644,6 +647,7 @@ rustc_queries! {
644647

645648
Codegen {
646649
query codegen_fn_attrs(_: DefId) -> CodegenFnAttrs {
650+
storage(ArenaCacheSelector<'tcx>)
647651
cache_on_disk_if { true }
648652
}
649653
}

src/librustc_middle/ty/mod.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -257,13 +257,13 @@ impl AssocItem {
257257
/// it is relatively expensive. Instead, items are indexed by `Symbol` and hygienic comparison is
258258
/// done only on items with the same name.
259259
#[derive(Debug, Clone, PartialEq, HashStable)]
260-
pub struct AssociatedItems {
261-
items: SortedIndexMultiMap<u32, Symbol, ty::AssocItem>,
260+
pub struct AssociatedItems<'tcx> {
261+
items: SortedIndexMultiMap<u32, Symbol, &'tcx ty::AssocItem>,
262262
}
263263

264-
impl AssociatedItems {
264+
impl<'tcx> AssociatedItems<'tcx> {
265265
/// Constructs an `AssociatedItems` map from a series of `ty::AssocItem`s in definition order.
266-
pub fn new(items_in_def_order: impl IntoIterator<Item = ty::AssocItem>) -> Self {
266+
pub fn new(items_in_def_order: impl IntoIterator<Item = &'tcx ty::AssocItem>) -> Self {
267267
let items = items_in_def_order.into_iter().map(|item| (item.ident.name, item)).collect();
268268
AssociatedItems { items }
269269
}
@@ -273,15 +273,15 @@ impl AssociatedItems {
273273
/// New code should avoid relying on definition order. If you need a particular associated item
274274
/// for a known trait, make that trait a lang item instead of indexing this array.
275275
pub fn in_definition_order(&self) -> impl '_ + Iterator<Item = &ty::AssocItem> {
276-
self.items.iter().map(|(_, v)| v)
276+
self.items.iter().map(|(_, v)| *v)
277277
}
278278

279279
/// Returns an iterator over all associated items with the given name, ignoring hygiene.
280280
pub fn filter_by_name_unhygienic(
281281
&self,
282282
name: Symbol,
283283
) -> impl '_ + Iterator<Item = &ty::AssocItem> {
284-
self.items.get_by_key(&name)
284+
self.items.get_by_key(&name).map(|v| *v)
285285
}
286286

287287
/// Returns an iterator over all associated items with the given name.
@@ -2672,7 +2672,7 @@ impl<'tcx> TyCtxt<'tcx> {
26722672
.and_then(|def_id| self.hir().get(self.hir().as_local_hir_id(def_id)).ident())
26732673
}
26742674

2675-
pub fn opt_associated_item(self, def_id: DefId) -> Option<AssocItem> {
2675+
pub fn opt_associated_item(self, def_id: DefId) -> Option<&'tcx AssocItem> {
26762676
let is_associated_item = if let Some(def_id) = def_id.as_local() {
26772677
match self.hir().get(self.hir().as_local_hir_id(def_id)) {
26782678
Node::TraitItem(_) | Node::ImplItem(_) => true,

src/librustc_mir_build/lints.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ crate fn check<'tcx>(tcx: TyCtxt<'tcx>, body: &Body<'tcx>, def_id: LocalDefId) {
2424
Some(AssocItem {
2525
container: AssocItemContainer::TraitContainer(trait_def_id), ..
2626
}) => {
27-
let trait_substs_count = tcx.generics_of(trait_def_id).count();
27+
let trait_substs_count = tcx.generics_of(*trait_def_id).count();
2828
&InternalSubsts::identity_for_item(tcx, def_id.to_def_id())[..trait_substs_count]
2929
}
3030
_ => &[],

src/librustc_passes/reachable.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ use rustc_target::spec::abi::Abi;
2323
// Returns true if the given item must be inlined because it may be
2424
// monomorphized or it was marked with `#[inline]`. This will only return
2525
// true for functions.
26-
fn item_might_be_inlined(tcx: TyCtxt<'tcx>, item: &hir::Item<'_>, attrs: CodegenFnAttrs) -> bool {
26+
fn item_might_be_inlined(tcx: TyCtxt<'tcx>, item: &hir::Item<'_>, attrs: &CodegenFnAttrs) -> bool {
2727
if attrs.requests_inline() {
2828
return true;
2929
}

src/librustc_ty/ty.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ fn associated_item_def_ids(tcx: TyCtxt<'_>, def_id: DefId) -> &[DefId] {
220220
}
221221
}
222222

223-
fn associated_items(tcx: TyCtxt<'_>, def_id: DefId) -> ty::AssociatedItems {
223+
fn associated_items(tcx: TyCtxt<'_>, def_id: DefId) -> ty::AssociatedItems<'_> {
224224
let items = tcx.associated_item_def_ids(def_id).iter().map(|did| tcx.associated_item(*did));
225225
ty::AssociatedItems::new(items)
226226
}

0 commit comments

Comments
 (0)