Only store a LocalDefId in hir::TraitItem.
This commit is contained in:
parent
cebbba081e
commit
a871a0f111
45 changed files with 139 additions and 125 deletions
|
@ -725,8 +725,7 @@ pub fn check_item_type<'tcx>(tcx: TyCtxt<'tcx>, it: &'tcx hir::Item<'tcx>) {
|
|||
fn_maybe_err(tcx, item.ident.span, abi);
|
||||
}
|
||||
hir::TraitItemKind::Type(.., Some(_default)) => {
|
||||
let item_def_id = tcx.hir().local_def_id(item.hir_id).to_def_id();
|
||||
let assoc_item = tcx.associated_item(item_def_id);
|
||||
let assoc_item = tcx.associated_item(item.def_id);
|
||||
let trait_substs =
|
||||
InternalSubsts::identity_for_item(tcx, it.def_id.to_def_id());
|
||||
let _: Result<_, rustc_errors::ErrorReported> = check_type_bounds(
|
||||
|
|
|
@ -823,8 +823,8 @@ fn compare_synthetic_generics<'tcx>(
|
|||
// FIXME: this is obviously suboptimal since the name can already be used
|
||||
// as another generic argument
|
||||
let new_name = tcx.sess.source_map().span_to_snippet(trait_span).ok()?;
|
||||
let trait_m = tcx.hir().local_def_id_to_hir_id(trait_m.def_id.as_local()?);
|
||||
let trait_m = tcx.hir().trait_item(hir::TraitItemId { hir_id: trait_m });
|
||||
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 });
|
||||
|
|
|
@ -197,7 +197,7 @@ pub fn check_trait_item(tcx: TyCtxt<'_>, def_id: LocalDefId) {
|
|||
_ => None,
|
||||
};
|
||||
check_object_unsafe_self_trait_by_name(tcx, &trait_item);
|
||||
check_associated_item(tcx, trait_item.hir_id, trait_item.span, method_sig);
|
||||
check_associated_item(tcx, trait_item.hir_id(), trait_item.span, method_sig);
|
||||
}
|
||||
|
||||
fn could_be_self(trait_def_id: LocalDefId, ty: &hir::Ty<'_>) -> bool {
|
||||
|
@ -213,7 +213,7 @@ fn could_be_self(trait_def_id: LocalDefId, ty: &hir::Ty<'_>) -> bool {
|
|||
/// Detect when an object unsafe trait is referring to itself in one of its associated items.
|
||||
/// When this is done, suggest using `Self` instead.
|
||||
fn check_object_unsafe_self_trait_by_name(tcx: TyCtxt<'_>, item: &hir::TraitItem<'_>) {
|
||||
let (trait_name, trait_def_id) = match tcx.hir().get(tcx.hir().get_parent_item(item.hir_id)) {
|
||||
let (trait_name, trait_def_id) = match tcx.hir().get(tcx.hir().get_parent_item(item.hir_id())) {
|
||||
hir::Node::Item(item) => match item.kind {
|
||||
hir::ItemKind::Trait(..) => (item.ident, item.def_id),
|
||||
_ => return,
|
||||
|
@ -1354,8 +1354,7 @@ impl Visitor<'tcx> for CheckTypeWellFormedVisitor<'tcx> {
|
|||
|
||||
fn visit_trait_item(&mut self, trait_item: &'tcx hir::TraitItem<'tcx>) {
|
||||
debug!("visit_trait_item: {:?}", trait_item);
|
||||
let def_id = self.tcx.hir().local_def_id(trait_item.hir_id);
|
||||
self.tcx.ensure().check_trait_item_well_formed(def_id);
|
||||
self.tcx.ensure().check_trait_item_well_formed(trait_item.def_id);
|
||||
hir_visit::walk_trait_item(self, trait_item);
|
||||
}
|
||||
|
||||
|
|
|
@ -281,7 +281,7 @@ impl Visitor<'tcx> for CollectItemTypesVisitor<'tcx> {
|
|||
}
|
||||
|
||||
fn visit_trait_item(&mut self, trait_item: &'tcx hir::TraitItem<'tcx>) {
|
||||
convert_trait_item(self.tcx, trait_item.hir_id);
|
||||
convert_trait_item(self.tcx, trait_item.trait_item_id());
|
||||
intravisit::walk_trait_item(self, trait_item);
|
||||
}
|
||||
|
||||
|
@ -804,23 +804,22 @@ fn convert_item(tcx: TyCtxt<'_>, item_id: hir::ItemId) {
|
|||
}
|
||||
}
|
||||
|
||||
fn convert_trait_item(tcx: TyCtxt<'_>, trait_item_id: hir::HirId) {
|
||||
let trait_item = tcx.hir().expect_trait_item(trait_item_id);
|
||||
let def_id = tcx.hir().local_def_id(trait_item.hir_id);
|
||||
tcx.ensure().generics_of(def_id);
|
||||
fn convert_trait_item(tcx: TyCtxt<'_>, trait_item_id: hir::TraitItemId) {
|
||||
let trait_item = tcx.hir().trait_item(trait_item_id);
|
||||
tcx.ensure().generics_of(trait_item_id.def_id);
|
||||
|
||||
match trait_item.kind {
|
||||
hir::TraitItemKind::Fn(..) => {
|
||||
tcx.ensure().type_of(def_id);
|
||||
tcx.ensure().fn_sig(def_id);
|
||||
tcx.ensure().type_of(trait_item_id.def_id);
|
||||
tcx.ensure().fn_sig(trait_item_id.def_id);
|
||||
}
|
||||
|
||||
hir::TraitItemKind::Const(.., Some(_)) => {
|
||||
tcx.ensure().type_of(def_id);
|
||||
tcx.ensure().type_of(trait_item_id.def_id);
|
||||
}
|
||||
|
||||
hir::TraitItemKind::Const(..) => {
|
||||
tcx.ensure().type_of(def_id);
|
||||
tcx.ensure().type_of(trait_item_id.def_id);
|
||||
// Account for `const C: _;`.
|
||||
let mut visitor = PlaceholderHirTyCollector::default();
|
||||
visitor.visit_trait_item(trait_item);
|
||||
|
@ -828,8 +827,8 @@ fn convert_trait_item(tcx: TyCtxt<'_>, trait_item_id: hir::HirId) {
|
|||
}
|
||||
|
||||
hir::TraitItemKind::Type(_, Some(_)) => {
|
||||
tcx.ensure().item_bounds(def_id);
|
||||
tcx.ensure().type_of(def_id);
|
||||
tcx.ensure().item_bounds(trait_item_id.def_id);
|
||||
tcx.ensure().type_of(trait_item_id.def_id);
|
||||
// Account for `type T = _;`.
|
||||
let mut visitor = PlaceholderHirTyCollector::default();
|
||||
visitor.visit_trait_item(trait_item);
|
||||
|
@ -837,7 +836,7 @@ fn convert_trait_item(tcx: TyCtxt<'_>, trait_item_id: hir::HirId) {
|
|||
}
|
||||
|
||||
hir::TraitItemKind::Type(_, None) => {
|
||||
tcx.ensure().item_bounds(def_id);
|
||||
tcx.ensure().item_bounds(trait_item_id.def_id);
|
||||
// #74612: Visit and try to find bad placeholders
|
||||
// even if there is no concrete type.
|
||||
let mut visitor = PlaceholderHirTyCollector::default();
|
||||
|
@ -847,7 +846,7 @@ fn convert_trait_item(tcx: TyCtxt<'_>, trait_item_id: hir::HirId) {
|
|||
}
|
||||
};
|
||||
|
||||
tcx.ensure().predicates_of(def_id);
|
||||
tcx.ensure().predicates_of(trait_item_id.def_id);
|
||||
}
|
||||
|
||||
fn convert_impl_item(tcx: TyCtxt<'_>, impl_item_id: hir::HirId) {
|
||||
|
|
|
@ -599,8 +599,7 @@ fn find_opaque_ty_constraints(tcx: TyCtxt<'_>, def_id: LocalDefId) -> Ty<'_> {
|
|||
}
|
||||
fn visit_trait_item(&mut self, it: &'tcx TraitItem<'tcx>) {
|
||||
debug!("find_existential_constraints: visiting {:?}", it);
|
||||
let def_id = self.tcx.hir().local_def_id(it.hir_id);
|
||||
self.check(def_id);
|
||||
self.check(it.def_id);
|
||||
intravisit::walk_trait_item(self, it);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -98,7 +98,7 @@ impl<'a, 'tcx, 'v> ItemLikeVisitor<'v> for ConstraintContext<'a, 'tcx> {
|
|||
|
||||
fn visit_trait_item(&mut self, trait_item: &hir::TraitItem<'_>) {
|
||||
if let hir::TraitItemKind::Fn(..) = trait_item.kind {
|
||||
self.visit_node_helper(trait_item.hir_id);
|
||||
self.visit_node_helper(trait_item.hir_id());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -159,7 +159,7 @@ impl<'a, 'tcx, 'v> ItemLikeVisitor<'v> for TermsContext<'a, 'tcx> {
|
|||
|
||||
fn visit_trait_item(&mut self, trait_item: &hir::TraitItem<'_>) {
|
||||
if let hir::TraitItemKind::Fn(..) = trait_item.kind {
|
||||
self.add_inferreds_for_item(trait_item.hir_id);
|
||||
self.add_inferreds_for_item(trait_item.hir_id());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue