1
Fork 0

Take a LocalDefId in expect_*item.

This commit is contained in:
Camille GILLOT 2021-10-20 22:38:10 +02:00
parent e6d2de9483
commit 5fb4648757
28 changed files with 95 additions and 137 deletions

View file

@ -32,7 +32,7 @@ pub(crate) fn target_from_impl_item<'tcx>(
match impl_item.kind {
hir::ImplItemKind::Const(..) => Target::AssocConst,
hir::ImplItemKind::Fn(..) => {
let parent_hir_id = tcx.hir().get_parent_item(impl_item.hir_id());
let parent_hir_id = tcx.hir().get_parent_item(impl_item.hir_id()).expect_owner();
let containing_item = tcx.hir().expect_item(parent_hir_id);
let containing_impl_is_for_trait = match &containing_item.kind {
hir::ItemKind::Impl(impl_) => impl_.of_trait.is_some(),
@ -582,7 +582,7 @@ impl CheckAttrVisitor<'tcx> {
Target::Impl => Some("implementation block"),
Target::ForeignMod => Some("extern block"),
Target::AssocTy => {
let parent_hir_id = self.tcx.hir().get_parent_item(hir_id);
let parent_hir_id = self.tcx.hir().get_parent_item(hir_id).expect_owner();
let containing_item = self.tcx.hir().expect_item(parent_hir_id);
if Target::from_item(containing_item) == Target::Impl {
Some("type alias in implementation block")
@ -591,7 +591,7 @@ impl CheckAttrVisitor<'tcx> {
}
}
Target::AssocConst => {
let parent_hir_id = self.tcx.hir().get_parent_item(hir_id);
let parent_hir_id = self.tcx.hir().get_parent_item(hir_id).expect_owner();
let containing_item = self.tcx.hir().expect_item(parent_hir_id);
// We can't link to trait impl's consts.
let err = "associated constant in trait implementation block";

View file

@ -173,8 +173,7 @@ impl<'tcx> ReachableContext<'tcx> {
// Check the impl. If the generics on the self
// type of the impl require inlining, this method
// does too.
let impl_hir_id = self.tcx.hir().local_def_id_to_hir_id(impl_did);
match self.tcx.hir().expect_item(impl_hir_id).kind {
match self.tcx.hir().expect_item(impl_did).kind {
hir::ItemKind::Impl { .. } => {
let generics = self.tcx.generics_of(impl_did);
generics.requires_monomorphization(self.tcx)