diff options
| author | Camille GILLOT <gillot.camille@gmail.com> | 2022-03-12 19:36:11 +0100 |
|---|---|---|
| committer | Camille GILLOT <gillot.camille@gmail.com> | 2022-08-01 21:38:16 +0200 |
| commit | 110f0656cb655f7f57b1649b11ff5bcfa2303b07 (patch) | |
| tree | 388ee504073c8ca77ceb2d3f5fe7cf679292d6bc /compiler/rustc_ty_utils/src | |
| parent | c9e134e1b609e571f4d7d18f91f0ccb1a0cb685d (diff) | |
| download | rust-110f0656cb655f7f57b1649b11ff5bcfa2303b07.tar.gz rust-110f0656cb655f7f57b1649b11ff5bcfa2303b07.zip | |
Store associated item defaultness in impl_defaultness.
Diffstat (limited to 'compiler/rustc_ty_utils/src')
| -rw-r--r-- | compiler/rustc_ty_utils/src/assoc.rs | 2 | ||||
| -rw-r--r-- | compiler/rustc_ty_utils/src/instance.rs | 2 | ||||
| -rw-r--r-- | compiler/rustc_ty_utils/src/ty.rs | 12 |
3 files changed, 8 insertions, 8 deletions
diff --git a/compiler/rustc_ty_utils/src/assoc.rs b/compiler/rustc_ty_utils/src/assoc.rs index 4142c999ca7..ffdcf1a7214 100644 --- a/compiler/rustc_ty_utils/src/assoc.rs +++ b/compiler/rustc_ty_utils/src/assoc.rs @@ -103,7 +103,6 @@ fn associated_item_from_trait_item_ref( name: trait_item_ref.ident.name, kind, vis: tcx.visibility(def_id), - defaultness: trait_item_ref.defaultness, 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()), @@ -127,7 +126,6 @@ fn associated_item_from_impl_item_ref( name: impl_item_ref.ident.name, kind, vis: tcx.visibility(def_id), - defaultness: impl_item_ref.defaultness, 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()), diff --git a/compiler/rustc_ty_utils/src/instance.rs b/compiler/rustc_ty_utils/src/instance.rs index 979e997f244..bd1d568cd9a 100644 --- a/compiler/rustc_ty_utils/src/instance.rs +++ b/compiler/rustc_ty_utils/src/instance.rs @@ -281,7 +281,7 @@ fn resolve_associated_item<'tcx>( } // If the item does not have a value, then we cannot return an instance. - if !leaf_def.item.defaultness.has_value() { + if !leaf_def.item.defaultness(tcx).has_value() { return Ok(None); } diff --git a/compiler/rustc_ty_utils/src/ty.rs b/compiler/rustc_ty_utils/src/ty.rs index b1af3051719..7007e76b86e 100644 --- a/compiler/rustc_ty_utils/src/ty.rs +++ b/compiler/rustc_ty_utils/src/ty.rs @@ -70,11 +70,13 @@ fn sized_constraint_for_ty<'tcx>( } fn impl_defaultness(tcx: TyCtxt<'_>, def_id: DefId) -> hir::Defaultness { - let item = tcx.hir().expect_item(def_id.expect_local()); - if let hir::ItemKind::Impl(impl_) = &item.kind { - impl_.defaultness - } else { - bug!("`impl_defaultness` called on {:?}", item); + match tcx.hir().get_by_def_id(def_id.expect_local()) { + hir::Node::Item(hir::Item { kind: hir::ItemKind::Impl(impl_), .. }) => impl_.defaultness, + hir::Node::ImplItem(hir::ImplItem { defaultness, .. }) + | hir::Node::TraitItem(hir::TraitItem { defaultness, .. }) => *defaultness, + node => { + bug!("`impl_defaultness` called on {:?}", node); + } } } |
