Store def_id_to_hir_id as variant in hir_owner.

If hir_owner is Owner(_), the LocalDefId is pointing to an owner, so the ItemLocalId is 0.
If the HIR node does not exist, we store Phantom.
Otherwise, we store the HirId associated to the LocalDefId.
This commit is contained in:
Camille GILLOT 2021-09-22 19:28:20 +02:00 committed by Santiago Pastorino
parent 009c1d0248
commit a0bcce4884
No known key found for this signature in database
GPG key ID: 8131A24E0C79EFAF
11 changed files with 123 additions and 112 deletions

View file

@ -1019,15 +1019,7 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> {
let hir_id = self.tcx.hir().local_def_id_to_hir_id(def_id);
// Ensure that the parent of the def is an item, not HRTB
let parent_id = self.tcx.hir().get_parent_node(hir_id);
// FIXME(cjgillot) Can this check be replaced by
// `let parent_is_item = parent_id.is_owner();`?
let parent_is_item = if let Some(parent_def_id) = parent_id.as_owner() {
matches!(self.tcx.hir().krate().owners.get(parent_def_id), Some(Some(_)),)
} else {
false
};
if !parent_is_item {
if !parent_id.is_owner() {
if !self.trait_definition_only {
struct_span_err!(
self.tcx.sess,