Allocate query Vecs on the arena.
This commit is contained in:
parent
607b858236
commit
3c0edc895f
8 changed files with 20 additions and 14 deletions
|
|
@ -39,7 +39,7 @@ pub fn report_object_safety_error(
|
|||
tcx: TyCtxt<'tcx>,
|
||||
span: Span,
|
||||
trait_def_id: DefId,
|
||||
violations: Vec<ObjectSafetyViolation>,
|
||||
violations: &[ObjectSafetyViolation],
|
||||
) -> DiagnosticBuilder<'tcx> {
|
||||
let trait_str = tcx.def_path_str(trait_def_id);
|
||||
let trait_span = tcx.hir().get_if_local(trait_def_id).and_then(|node| match node {
|
||||
|
|
|
|||
|
|
@ -1331,13 +1331,13 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
fn get_fn_param_names(&self, id: DefIndex) -> Vec<ast::Name> {
|
||||
fn get_fn_param_names(&self, tcx: TyCtxt<'tcx>, id: DefIndex) -> &'tcx [ast::Name] {
|
||||
let param_names = match self.kind(id) {
|
||||
EntryKind::Fn(data) | EntryKind::ForeignFn(data) => data.decode(self).param_names,
|
||||
EntryKind::AssocFn(data) => data.decode(self).fn_data.param_names,
|
||||
_ => Lazy::empty(),
|
||||
};
|
||||
param_names.decode(self).collect()
|
||||
tcx.arena.alloc_from_iter(param_names.decode(self))
|
||||
}
|
||||
|
||||
fn exported_symbols(
|
||||
|
|
|
|||
|
|
@ -144,7 +144,7 @@ provide! { <'tcx> tcx, def_id, other, cdata,
|
|||
// a `fn` when encoding, so the dep-tracking wouldn't work.
|
||||
// This is only used by rustdoc anyway, which shouldn't have
|
||||
// incremental recompilation ever enabled.
|
||||
fn_arg_names => { cdata.get_fn_param_names(def_id.index) }
|
||||
fn_arg_names => { cdata.get_fn_param_names(tcx, def_id.index) }
|
||||
rendered_const => { cdata.get_rendered_const(def_id.index) }
|
||||
impl_parent => { cdata.get_parent_impl(def_id.index) }
|
||||
trait_of_item => { cdata.get_trait_of_item(def_id.index) }
|
||||
|
|
|
|||
|
|
@ -116,6 +116,7 @@ macro_rules! arena_types {
|
|||
[few] crate_variances: rustc_middle::ty::CrateVariancesMap<'tcx>,
|
||||
[few] inferred_outlives_crate: rustc_middle::ty::CratePredicatesMap<'tcx>,
|
||||
[] upvars: rustc_data_structures::fx::FxIndexMap<rustc_hir::HirId, rustc_hir::Upvar>,
|
||||
[] object_safety_violations: rustc_middle::traits::ObjectSafetyViolation,
|
||||
|
||||
// Interned types
|
||||
[] tys: rustc_middle::ty::TyS<$tcx>,
|
||||
|
|
|
|||
|
|
@ -652,7 +652,7 @@ rustc_queries! {
|
|||
}
|
||||
|
||||
Other {
|
||||
query fn_arg_names(_: DefId) -> Vec<ast::Name> {}
|
||||
query fn_arg_names(_: DefId) -> &'tcx [ast::Name] {}
|
||||
/// Gets the rendered value of the specified constant or associated constant.
|
||||
/// Used by rustdoc.
|
||||
query rendered_const(_: DefId) -> String {}
|
||||
|
|
@ -699,7 +699,7 @@ rustc_queries! {
|
|||
desc { |tcx| "building specialization graph of trait `{}`", tcx.def_path_str(key) }
|
||||
cache_on_disk_if { true }
|
||||
}
|
||||
query object_safety_violations(key: DefId) -> Vec<traits::ObjectSafetyViolation> {
|
||||
query object_safety_violations(key: DefId) -> &'tcx [traits::ObjectSafetyViolation] {
|
||||
desc { |tcx| "determine object safety of trait `{}`", tcx.def_path_str(key) }
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -47,13 +47,17 @@ pub fn astconv_object_safety_violations(
|
|||
violations
|
||||
}
|
||||
|
||||
fn object_safety_violations(tcx: TyCtxt<'_>, trait_def_id: DefId) -> Vec<ObjectSafetyViolation> {
|
||||
fn object_safety_violations(
|
||||
tcx: TyCtxt<'tcx>,
|
||||
trait_def_id: DefId,
|
||||
) -> &'tcx [ObjectSafetyViolation] {
|
||||
debug_assert!(tcx.generics_of(trait_def_id).has_self);
|
||||
debug!("object_safety_violations: {:?}", trait_def_id);
|
||||
|
||||
traits::supertrait_def_ids(tcx, trait_def_id)
|
||||
.flat_map(|def_id| object_safety_violations_for_trait(tcx, def_id))
|
||||
.collect()
|
||||
tcx.arena.alloc_from_iter(
|
||||
traits::supertrait_def_ids(tcx, trait_def_id)
|
||||
.flat_map(|def_id| object_safety_violations_for_trait(tcx, def_id)),
|
||||
)
|
||||
}
|
||||
|
||||
/// We say a method is *vtable safe* if it can be invoked on a trait
|
||||
|
|
|
|||
|
|
@ -1582,7 +1582,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
|||
tcx,
|
||||
span,
|
||||
item.trait_ref().def_id(),
|
||||
object_safety_violations,
|
||||
&object_safety_violations[..],
|
||||
)
|
||||
.emit();
|
||||
return tcx.types.err;
|
||||
|
|
|
|||
|
|
@ -973,10 +973,11 @@ impl<'tcx> Clean<FnDecl> for (DefId, ty::PolyFnSig<'tcx>) {
|
|||
fn clean(&self, cx: &DocContext<'_>) -> FnDecl {
|
||||
let (did, sig) = *self;
|
||||
let mut names = if cx.tcx.hir().as_local_hir_id(did).is_some() {
|
||||
vec![].into_iter()
|
||||
&[]
|
||||
} else {
|
||||
cx.tcx.fn_arg_names(did).into_iter()
|
||||
};
|
||||
cx.tcx.fn_arg_names(did)
|
||||
}
|
||||
.iter();
|
||||
|
||||
FnDecl {
|
||||
output: Return(sig.skip_binder().output().clean(cx)),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue