Remove DefId from AssocItemContainer.
This commit is contained in:
parent
8ee4446ee5
commit
d7ea161b7e
40 changed files with 190 additions and 220 deletions
|
@ -1,6 +1,6 @@
|
|||
use rustc_data_structures::fx::FxHashMap;
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::def_id::{DefId, LocalDefId};
|
||||
use rustc_hir::def_id::DefId;
|
||||
use rustc_middle::ty::{self, TyCtxt};
|
||||
|
||||
pub fn provide(providers: &mut ty::query::Providers) {
|
||||
|
@ -44,10 +44,7 @@ fn impl_item_implementor_ids(tcx: TyCtxt<'_>, impl_id: DefId) -> FxHashMap<DefId
|
|||
/// returns the `DefId` of the trait that the trait item belongs to;
|
||||
/// otherwise, returns `None`.
|
||||
fn trait_of_item(tcx: TyCtxt<'_>, def_id: DefId) -> Option<DefId> {
|
||||
tcx.opt_associated_item(def_id).and_then(|associated_item| match associated_item.container {
|
||||
ty::TraitContainer(def_id) => Some(def_id),
|
||||
ty::ImplContainer(_) => None,
|
||||
})
|
||||
tcx.opt_associated_item(def_id).and_then(|associated_item| associated_item.trait_container(tcx))
|
||||
}
|
||||
|
||||
fn associated_item(tcx: TyCtxt<'_>, def_id: DefId) -> ty::AssocItem {
|
||||
|
@ -59,7 +56,7 @@ fn associated_item(tcx: TyCtxt<'_>, def_id: DefId) -> ty::AssocItem {
|
|||
if let Some(impl_item_ref) =
|
||||
impl_.items.iter().find(|i| i.id.def_id.to_def_id() == def_id)
|
||||
{
|
||||
let assoc_item = associated_item_from_impl_item_ref(parent_def_id, impl_item_ref);
|
||||
let assoc_item = associated_item_from_impl_item_ref(impl_item_ref);
|
||||
debug_assert_eq!(assoc_item.def_id, def_id);
|
||||
return assoc_item;
|
||||
}
|
||||
|
@ -69,7 +66,7 @@ fn associated_item(tcx: TyCtxt<'_>, def_id: DefId) -> ty::AssocItem {
|
|||
if let Some(trait_item_ref) =
|
||||
trait_item_refs.iter().find(|i| i.id.def_id.to_def_id() == def_id)
|
||||
{
|
||||
let assoc_item = associated_item_from_trait_item_ref(parent_def_id, trait_item_ref);
|
||||
let assoc_item = associated_item_from_trait_item_ref(trait_item_ref);
|
||||
debug_assert_eq!(assoc_item.def_id, def_id);
|
||||
return assoc_item;
|
||||
}
|
||||
|
@ -85,10 +82,7 @@ fn associated_item(tcx: TyCtxt<'_>, def_id: DefId) -> ty::AssocItem {
|
|||
)
|
||||
}
|
||||
|
||||
fn associated_item_from_trait_item_ref(
|
||||
parent_def_id: LocalDefId,
|
||||
trait_item_ref: &hir::TraitItemRef,
|
||||
) -> ty::AssocItem {
|
||||
fn associated_item_from_trait_item_ref(trait_item_ref: &hir::TraitItemRef) -> ty::AssocItem {
|
||||
let def_id = trait_item_ref.id.def_id;
|
||||
let (kind, has_self) = match trait_item_ref.kind {
|
||||
hir::AssocItemKind::Const => (ty::AssocKind::Const, false),
|
||||
|
@ -101,15 +95,12 @@ fn associated_item_from_trait_item_ref(
|
|||
kind,
|
||||
def_id: def_id.to_def_id(),
|
||||
trait_item_def_id: Some(def_id.to_def_id()),
|
||||
container: ty::TraitContainer(parent_def_id.to_def_id()),
|
||||
container: ty::TraitContainer,
|
||||
fn_has_self_parameter: has_self,
|
||||
}
|
||||
}
|
||||
|
||||
fn associated_item_from_impl_item_ref(
|
||||
parent_def_id: LocalDefId,
|
||||
impl_item_ref: &hir::ImplItemRef,
|
||||
) -> ty::AssocItem {
|
||||
fn associated_item_from_impl_item_ref(impl_item_ref: &hir::ImplItemRef) -> ty::AssocItem {
|
||||
let def_id = impl_item_ref.id.def_id;
|
||||
let (kind, has_self) = match impl_item_ref.kind {
|
||||
hir::AssocItemKind::Const => (ty::AssocKind::Const, false),
|
||||
|
@ -122,7 +113,7 @@ fn associated_item_from_impl_item_ref(
|
|||
kind,
|
||||
def_id: def_id.to_def_id(),
|
||||
trait_item_def_id: impl_item_ref.trait_item_def_id,
|
||||
container: ty::ImplContainer(parent_def_id.to_def_id()),
|
||||
container: ty::ImplContainer,
|
||||
fn_has_self_parameter: has_self,
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue