Only store a LocalDefId in hir::ImplItem.
This commit is contained in:
parent
a871a0f111
commit
786a80e9ea
56 changed files with 163 additions and 165 deletions
|
@ -928,7 +928,7 @@ pub(super) fn check_impl_items_against_trait<'tcx>(
|
|||
// Check existing impl methods to see if they are both present in trait
|
||||
// and compatible with trait signature
|
||||
for impl_item in impl_items {
|
||||
let ty_impl_item = tcx.associated_item(tcx.hir().local_def_id(impl_item.hir_id));
|
||||
let ty_impl_item = tcx.associated_item(impl_item.def_id);
|
||||
|
||||
let mut items =
|
||||
associated_items.filter_by_name(tcx, ty_impl_item.ident, impl_trait_ref.def_id);
|
||||
|
|
|
@ -826,8 +826,8 @@ fn compare_synthetic_generics<'tcx>(
|
|||
let trait_m = trait_m.def_id.as_local()?;
|
||||
let trait_m = tcx.hir().trait_item(hir::TraitItemId { def_id: trait_m });
|
||||
|
||||
let impl_m = tcx.hir().local_def_id_to_hir_id(impl_m.def_id.as_local()?);
|
||||
let impl_m = tcx.hir().impl_item(hir::ImplItemId { hir_id: impl_m });
|
||||
let impl_m = impl_m.def_id.as_local()?;
|
||||
let impl_m = tcx.hir().impl_item(hir::ImplItemId { def_id: impl_m });
|
||||
|
||||
// in case there are no generics, take the spot between the function name
|
||||
// and the opening paren of the argument list
|
||||
|
@ -860,8 +860,8 @@ fn compare_synthetic_generics<'tcx>(
|
|||
(None, Some(hir::SyntheticTyParamKind::ImplTrait)) => {
|
||||
err.span_label(impl_span, "expected `impl Trait`, found generic parameter");
|
||||
(|| {
|
||||
let impl_m = tcx.hir().local_def_id_to_hir_id(impl_m.def_id.as_local()?);
|
||||
let impl_m = tcx.hir().impl_item(hir::ImplItemId { hir_id: impl_m });
|
||||
let impl_m = impl_m.def_id.as_local()?;
|
||||
let impl_m = tcx.hir().impl_item(hir::ImplItemId { def_id: impl_m });
|
||||
let input_tys = match impl_m.kind {
|
||||
hir::ImplItemKind::Fn(ref sig, _) => sig.decl.inputs,
|
||||
_ => unreachable!(),
|
||||
|
|
|
@ -271,7 +271,7 @@ pub fn check_impl_item(tcx: TyCtxt<'_>, def_id: LocalDefId) {
|
|||
_ => None,
|
||||
};
|
||||
|
||||
check_associated_item(tcx, impl_item.hir_id, impl_item.span, method_sig);
|
||||
check_associated_item(tcx, impl_item.hir_id(), impl_item.span, method_sig);
|
||||
}
|
||||
|
||||
fn check_param_wf(tcx: TyCtxt<'_>, param: &hir::GenericParam<'_>) {
|
||||
|
@ -1360,8 +1360,7 @@ impl Visitor<'tcx> for CheckTypeWellFormedVisitor<'tcx> {
|
|||
|
||||
fn visit_impl_item(&mut self, impl_item: &'tcx hir::ImplItem<'tcx>) {
|
||||
debug!("visit_impl_item: {:?}", impl_item);
|
||||
let def_id = self.tcx.hir().local_def_id(impl_item.hir_id);
|
||||
self.tcx.ensure().check_impl_item_well_formed(def_id);
|
||||
self.tcx.ensure().check_impl_item_well_formed(impl_item.def_id);
|
||||
hir_visit::walk_impl_item(self, impl_item);
|
||||
}
|
||||
|
||||
|
|
|
@ -286,7 +286,7 @@ impl Visitor<'tcx> for CollectItemTypesVisitor<'tcx> {
|
|||
}
|
||||
|
||||
fn visit_impl_item(&mut self, impl_item: &'tcx hir::ImplItem<'tcx>) {
|
||||
convert_impl_item(self.tcx, impl_item.hir_id);
|
||||
convert_impl_item(self.tcx, impl_item.impl_item_id());
|
||||
intravisit::walk_impl_item(self, impl_item);
|
||||
}
|
||||
}
|
||||
|
@ -849,12 +849,12 @@ fn convert_trait_item(tcx: TyCtxt<'_>, trait_item_id: hir::TraitItemId) {
|
|||
tcx.ensure().predicates_of(trait_item_id.def_id);
|
||||
}
|
||||
|
||||
fn convert_impl_item(tcx: TyCtxt<'_>, impl_item_id: hir::HirId) {
|
||||
let def_id = tcx.hir().local_def_id(impl_item_id);
|
||||
fn convert_impl_item(tcx: TyCtxt<'_>, impl_item_id: hir::ImplItemId) {
|
||||
let def_id = impl_item_id.def_id;
|
||||
tcx.ensure().generics_of(def_id);
|
||||
tcx.ensure().type_of(def_id);
|
||||
tcx.ensure().predicates_of(def_id);
|
||||
let impl_item = tcx.hir().expect_impl_item(impl_item_id);
|
||||
let impl_item = tcx.hir().impl_item(impl_item_id);
|
||||
match impl_item.kind {
|
||||
hir::ImplItemKind::Fn(..) => {
|
||||
tcx.ensure().fn_sig(def_id);
|
||||
|
|
|
@ -590,10 +590,9 @@ fn find_opaque_ty_constraints(tcx: TyCtxt<'_>, def_id: LocalDefId) -> Ty<'_> {
|
|||
}
|
||||
fn visit_impl_item(&mut self, it: &'tcx ImplItem<'tcx>) {
|
||||
debug!("find_existential_constraints: visiting {:?}", it);
|
||||
let def_id = self.tcx.hir().local_def_id(it.hir_id);
|
||||
// The opaque type itself or its children are not within its reveal scope.
|
||||
if def_id.to_def_id() != self.def_id {
|
||||
self.check(def_id);
|
||||
if it.def_id.to_def_id() != self.def_id {
|
||||
self.check(it.def_id);
|
||||
intravisit::walk_impl_item(self, it);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -130,7 +130,7 @@ fn enforce_impl_params_are_constrained(
|
|||
// Disallow unconstrained lifetimes, but only if they appear in assoc types.
|
||||
let lifetimes_in_associated_types: FxHashSet<_> = impl_item_refs
|
||||
.iter()
|
||||
.map(|item_ref| tcx.hir().local_def_id(item_ref.id.hir_id))
|
||||
.map(|item_ref| item_ref.id.def_id)
|
||||
.flat_map(|def_id| {
|
||||
let item = tcx.associated_item(def_id);
|
||||
match item.kind {
|
||||
|
|
|
@ -104,7 +104,7 @@ impl<'a, 'tcx, 'v> ItemLikeVisitor<'v> for ConstraintContext<'a, 'tcx> {
|
|||
|
||||
fn visit_impl_item(&mut self, impl_item: &hir::ImplItem<'_>) {
|
||||
if let hir::ImplItemKind::Fn(..) = impl_item.kind {
|
||||
self.visit_node_helper(impl_item.hir_id);
|
||||
self.visit_node_helper(impl_item.hir_id());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -165,7 +165,7 @@ impl<'a, 'tcx, 'v> ItemLikeVisitor<'v> for TermsContext<'a, 'tcx> {
|
|||
|
||||
fn visit_impl_item(&mut self, impl_item: &hir::ImplItem<'_>) {
|
||||
if let hir::ImplItemKind::Fn(..) = impl_item.kind {
|
||||
self.add_inferreds_for_item(impl_item.hir_id);
|
||||
self.add_inferreds_for_item(impl_item.hir_id());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue