Update associated_item_def_ids
This commit is contained in:
parent
27cc0db7a2
commit
4ba144d5dd
4 changed files with 20 additions and 17 deletions
|
@ -262,7 +262,7 @@ rustc_queries! {
|
|||
|
||||
Other {
|
||||
/// Maps from an impl/trait `DefId to a list of the `DefId`s of its items.
|
||||
query associated_item_def_ids(_: DefId) -> Lrc<Vec<DefId>> {}
|
||||
query associated_item_def_ids(_: DefId) -> &'tcx [DefId] {}
|
||||
|
||||
/// Maps from a trait item to the trait item "descriptor".
|
||||
query associated_item(_: DefId) -> ty::AssociatedItem {}
|
||||
|
|
|
@ -3106,7 +3106,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
|
|||
|
||||
pub struct AssociatedItemsIterator<'a, 'gcx: 'tcx, 'tcx: 'a> {
|
||||
tcx: TyCtxt<'a, 'gcx, 'tcx>,
|
||||
def_ids: Lrc<Vec<DefId>>,
|
||||
def_ids: &'gcx [DefId],
|
||||
next_index: usize,
|
||||
}
|
||||
|
||||
|
@ -3183,26 +3183,27 @@ fn adt_sized_constraint<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
|||
|
||||
fn associated_item_def_ids<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
def_id: DefId)
|
||||
-> Lrc<Vec<DefId>> {
|
||||
-> &'tcx [DefId] {
|
||||
let id = tcx.hir().as_local_hir_id(def_id).unwrap();
|
||||
let item = tcx.hir().expect_item_by_hir_id(id);
|
||||
let vec: Vec<_> = match item.node {
|
||||
match item.node {
|
||||
hir::ItemKind::Trait(.., ref trait_item_refs) => {
|
||||
trait_item_refs.iter()
|
||||
.map(|trait_item_ref| trait_item_ref.id)
|
||||
.map(|id| tcx.hir().local_def_id_from_hir_id(id.hir_id))
|
||||
.collect()
|
||||
tcx.arena.alloc_from_iter(
|
||||
trait_item_refs.iter()
|
||||
.map(|trait_item_ref| trait_item_ref.id)
|
||||
.map(|id| tcx.hir().local_def_id_from_hir_id(id.hir_id))
|
||||
)
|
||||
}
|
||||
hir::ItemKind::Impl(.., ref impl_item_refs) => {
|
||||
impl_item_refs.iter()
|
||||
.map(|impl_item_ref| impl_item_ref.id)
|
||||
.map(|id| tcx.hir().local_def_id_from_hir_id(id.hir_id))
|
||||
.collect()
|
||||
tcx.arena.alloc_from_iter(
|
||||
impl_item_refs.iter()
|
||||
.map(|impl_item_ref| impl_item_ref.id)
|
||||
.map(|id| tcx.hir().local_def_id_from_hir_id(id.hir_id))
|
||||
)
|
||||
}
|
||||
hir::ItemKind::TraitAlias(..) => vec![],
|
||||
hir::ItemKind::TraitAlias(..) => &[],
|
||||
_ => span_bug!(item.span, "associated_item_def_ids: not impl or trait")
|
||||
};
|
||||
Lrc::new(vec)
|
||||
}
|
||||
}
|
||||
|
||||
fn def_span<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> Span {
|
||||
|
|
|
@ -13,6 +13,7 @@ crate-type = ["dylib"]
|
|||
flate2 = "1.0"
|
||||
log = "0.4"
|
||||
memmap = "0.6"
|
||||
smallvec = { version = "0.6.7", features = ["union", "may_dangle"] }
|
||||
rustc = { path = "../librustc" }
|
||||
rustc_data_structures = { path = "../librustc_data_structures" }
|
||||
errors = { path = "../librustc_errors", package = "rustc_errors" }
|
||||
|
|
|
@ -21,6 +21,7 @@ use rustc::hir::map::definitions::DefPathTable;
|
|||
use rustc::util::nodemap::DefIdMap;
|
||||
use rustc_data_structures::svh::Svh;
|
||||
|
||||
use smallvec::SmallVec;
|
||||
use std::any::Any;
|
||||
use rustc_data_structures::sync::Lrc;
|
||||
use std::sync::Arc;
|
||||
|
@ -108,10 +109,10 @@ provide! { <'tcx> tcx, def_id, other, cdata,
|
|||
}
|
||||
variances_of => { tcx.arena.alloc_from_iter(cdata.get_item_variances(def_id.index)) }
|
||||
associated_item_def_ids => {
|
||||
let mut result = vec![];
|
||||
let mut result = SmallVec::<[_; 8]>::new();
|
||||
cdata.each_child_of_item(def_id.index,
|
||||
|child| result.push(child.res.def_id()), tcx.sess);
|
||||
Lrc::new(result)
|
||||
tcx.arena.alloc_slice(&result)
|
||||
}
|
||||
associated_item => { cdata.get_associated_item(def_id.index) }
|
||||
impl_trait_ref => { cdata.get_impl_trait(def_id.index, tcx) }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue