Add query to avoid name comparison in leaf_def
This commit is contained in:
parent
1b057a33bd
commit
3b7d496f72
8 changed files with 114 additions and 89 deletions
|
@ -1,3 +1,4 @@
|
|||
use rustc_data_structures::fx::FxHashMap;
|
||||
use rustc_errors::struct_span_err;
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::def_id::{DefId, LocalDefId};
|
||||
|
@ -8,6 +9,7 @@ pub fn provide(providers: &mut ty::query::Providers) {
|
|||
associated_item,
|
||||
associated_item_def_ids,
|
||||
associated_items,
|
||||
impl_item_implementor_ids,
|
||||
trait_of_item,
|
||||
..*providers
|
||||
};
|
||||
|
@ -32,6 +34,13 @@ fn associated_items(tcx: TyCtxt<'_>, def_id: DefId) -> ty::AssocItems<'_> {
|
|||
ty::AssocItems::new(items)
|
||||
}
|
||||
|
||||
fn impl_item_implementor_ids(tcx: TyCtxt<'_>, impl_id: DefId) -> FxHashMap<DefId, DefId> {
|
||||
tcx.associated_items(impl_id)
|
||||
.in_definition_order()
|
||||
.filter_map(|item| item.trait_item_def_id.map(|trait_item| (trait_item, item.def_id)))
|
||||
.collect()
|
||||
}
|
||||
|
||||
/// If the given `DefId` describes an item belonging to a trait,
|
||||
/// returns the `DefId` of the trait that the trait item belongs to;
|
||||
/// otherwise, returns `None`.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue