1
Fork 0

Auto merge of #81611 - cjgillot:meowner, r=estebank

Only store a LocalDefId in some HIR nodes

Some HIR nodes are guaranteed to be HIR owners: Item, TraitItem, ImplItem, ForeignItem and MacroDef.
As a consequence, we do not need to store the `HirId`'s `local_id`, and we can directly store a `LocalDefId`.

This allows to avoid a bit of the dance with `tcx.hir().local_def_id` and `tcx.hir().local_def_id_to_hir_id` mappings.
This commit is contained in:
bors 2021-02-16 22:14:32 +00:00
commit 8fe989dd76
117 changed files with 1127 additions and 1191 deletions

View file

@ -821,7 +821,7 @@ fn foo(&self) -> Self::T { String::new() }
// an assoc type as a return type (#72076).
if let hir::Defaultness::Default { has_value: true } = item.defaultness
{
if self.type_of(self.hir().local_def_id(item.id.hir_id)) == found {
if self.type_of(item.id.def_id) == found {
db.span_label(
item.span,
"associated type defaults can't be assumed inside the \
@ -841,7 +841,7 @@ fn foo(&self) -> Self::T { String::new() }
})) => {
for item in &items[..] {
if let hir::AssocItemKind::Type = item.kind {
if self.type_of(self.hir().local_def_id(item.id.hir_id)) == found {
if self.type_of(item.id.def_id) == found {
db.span_label(item.span, "expected this associated type");
return true;
}