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

Commit 3c0edc8

Browse files
committed
Allocate query Vecs on the arena.
1 parent 607b858 commit 3c0edc8

File tree

8 files changed

+20
-14
lines changed

8 files changed

+20
-14
lines changed

src/librustc_infer/traits/error_reporting/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ pub fn report_object_safety_error(
3939
tcx: TyCtxt<'tcx>,
4040
span: Span,
4141
trait_def_id: DefId,
42-
violations: Vec<ObjectSafetyViolation>,
42+
violations: &[ObjectSafetyViolation],
4343
) -> DiagnosticBuilder<'tcx> {
4444
let trait_str = tcx.def_path_str(trait_def_id);
4545
let trait_span = tcx.hir().get_if_local(trait_def_id).and_then(|node| match node {

src/librustc_metadata/rmeta/decoder.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1331,13 +1331,13 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
13311331
}
13321332
}
13331333

1334-
fn get_fn_param_names(&self, id: DefIndex) -> Vec<ast::Name> {
1334+
fn get_fn_param_names(&self, tcx: TyCtxt<'tcx>, id: DefIndex) -> &'tcx [ast::Name] {
13351335
let param_names = match self.kind(id) {
13361336
EntryKind::Fn(data) | EntryKind::ForeignFn(data) => data.decode(self).param_names,
13371337
EntryKind::AssocFn(data) => data.decode(self).fn_data.param_names,
13381338
_ => Lazy::empty(),
13391339
};
1340-
param_names.decode(self).collect()
1340+
tcx.arena.alloc_from_iter(param_names.decode(self))
13411341
}
13421342

13431343
fn exported_symbols(

src/librustc_metadata/rmeta/decoder/cstore_impl.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ provide! { <'tcx> tcx, def_id, other, cdata,
144144
// a `fn` when encoding, so the dep-tracking wouldn't work.
145145
// This is only used by rustdoc anyway, which shouldn't have
146146
// incremental recompilation ever enabled.
147-
fn_arg_names => { cdata.get_fn_param_names(def_id.index) }
147+
fn_arg_names => { cdata.get_fn_param_names(tcx, def_id.index) }
148148
rendered_const => { cdata.get_rendered_const(def_id.index) }
149149
impl_parent => { cdata.get_parent_impl(def_id.index) }
150150
trait_of_item => { cdata.get_trait_of_item(def_id.index) }

src/librustc_middle/arena.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ macro_rules! arena_types {
116116
[few] crate_variances: rustc_middle::ty::CrateVariancesMap<'tcx>,
117117
[few] inferred_outlives_crate: rustc_middle::ty::CratePredicatesMap<'tcx>,
118118
[] upvars: rustc_data_structures::fx::FxIndexMap<rustc_hir::HirId, rustc_hir::Upvar>,
119+
[] object_safety_violations: rustc_middle::traits::ObjectSafetyViolation,
119120

120121
// Interned types
121122
[] tys: rustc_middle::ty::TyS<$tcx>,

src/librustc_middle/query/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -652,7 +652,7 @@ rustc_queries! {
652652
}
653653

654654
Other {
655-
query fn_arg_names(_: DefId) -> Vec<ast::Name> {}
655+
query fn_arg_names(_: DefId) -> &'tcx [ast::Name] {}
656656
/// Gets the rendered value of the specified constant or associated constant.
657657
/// Used by rustdoc.
658658
query rendered_const(_: DefId) -> String {}
@@ -699,7 +699,7 @@ rustc_queries! {
699699
desc { |tcx| "building specialization graph of trait `{}`", tcx.def_path_str(key) }
700700
cache_on_disk_if { true }
701701
}
702-
query object_safety_violations(key: DefId) -> Vec<traits::ObjectSafetyViolation> {
702+
query object_safety_violations(key: DefId) -> &'tcx [traits::ObjectSafetyViolation] {
703703
desc { |tcx| "determine object safety of trait `{}`", tcx.def_path_str(key) }
704704
}
705705

src/librustc_trait_selection/traits/object_safety.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,17 @@ pub fn astconv_object_safety_violations(
4747
violations
4848
}
4949

50-
fn object_safety_violations(tcx: TyCtxt<'_>, trait_def_id: DefId) -> Vec<ObjectSafetyViolation> {
50+
fn object_safety_violations(
51+
tcx: TyCtxt<'tcx>,
52+
trait_def_id: DefId,
53+
) -> &'tcx [ObjectSafetyViolation] {
5154
debug_assert!(tcx.generics_of(trait_def_id).has_self);
5255
debug!("object_safety_violations: {:?}", trait_def_id);
5356

54-
traits::supertrait_def_ids(tcx, trait_def_id)
55-
.flat_map(|def_id| object_safety_violations_for_trait(tcx, def_id))
56-
.collect()
57+
tcx.arena.alloc_from_iter(
58+
traits::supertrait_def_ids(tcx, trait_def_id)
59+
.flat_map(|def_id| object_safety_violations_for_trait(tcx, def_id)),
60+
)
5761
}
5862

5963
/// We say a method is *vtable safe* if it can be invoked on a trait

src/librustc_typeck/astconv.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1582,7 +1582,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
15821582
tcx,
15831583
span,
15841584
item.trait_ref().def_id(),
1585-
object_safety_violations,
1585+
&object_safety_violations[..],
15861586
)
15871587
.emit();
15881588
return tcx.types.err;

src/librustdoc/clean/mod.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -973,10 +973,11 @@ impl<'tcx> Clean<FnDecl> for (DefId, ty::PolyFnSig<'tcx>) {
973973
fn clean(&self, cx: &DocContext<'_>) -> FnDecl {
974974
let (did, sig) = *self;
975975
let mut names = if cx.tcx.hir().as_local_hir_id(did).is_some() {
976-
vec![].into_iter()
976+
&[]
977977
} else {
978-
cx.tcx.fn_arg_names(did).into_iter()
979-
};
978+
cx.tcx.fn_arg_names(did)
979+
}
980+
.iter();
980981

981982
FnDecl {
982983
output: Return(sig.skip_binder().output().clean(cx)),

0 commit comments

Comments
 (0)