Store associated item defaultness in impl_defaultness.
This commit is contained in:
parent
c9e134e1b6
commit
110f0656cb
25 changed files with 89 additions and 107 deletions
|
@ -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()),
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue