Return a LocalDefId in get_parent_item.
This commit is contained in:
parent
5a123c265b
commit
60064726ae
51 changed files with 151 additions and 140 deletions
|
@ -13,7 +13,7 @@ use rustc_data_structures::fx::FxHashMap;
|
|||
use rustc_errors::{pluralize, struct_span_err, Applicability};
|
||||
use rustc_feature::{AttributeDuplicates, AttributeType, BuiltinAttribute, BUILTIN_ATTRIBUTE_MAP};
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::def_id::LocalDefId;
|
||||
use rustc_hir::def_id::{LocalDefId, CRATE_DEF_ID};
|
||||
use rustc_hir::intravisit::{self, NestedVisitorMap, Visitor};
|
||||
use rustc_hir::{self, FnSig, ForeignItem, HirId, Item, ItemKind, TraitItem, CRATE_HIR_ID};
|
||||
use rustc_hir::{MethodKind, Target};
|
||||
|
@ -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()).expect_owner();
|
||||
let parent_hir_id = tcx.hir().get_parent_item(impl_item.hir_id());
|
||||
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<'_> {
|
|||
Target::Impl => Some("implementation block"),
|
||||
Target::ForeignMod => Some("extern block"),
|
||||
Target::AssocTy => {
|
||||
let parent_hir_id = self.tcx.hir().get_parent_item(hir_id).expect_owner();
|
||||
let parent_hir_id = self.tcx.hir().get_parent_item(hir_id);
|
||||
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<'_> {
|
|||
}
|
||||
}
|
||||
Target::AssocConst => {
|
||||
let parent_hir_id = self.tcx.hir().get_parent_item(hir_id).expect_owner();
|
||||
let parent_hir_id = self.tcx.hir().get_parent_item(hir_id);
|
||||
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";
|
||||
|
@ -832,7 +832,7 @@ impl CheckAttrVisitor<'_> {
|
|||
let mut err = lint.build(
|
||||
"this attribute can only be applied at the crate level",
|
||||
);
|
||||
if attr.style == AttrStyle::Outer && self.tcx.hir().get_parent_item(hir_id) == CRATE_HIR_ID {
|
||||
if attr.style == AttrStyle::Outer && self.tcx.hir().get_parent_item(hir_id) == CRATE_DEF_ID {
|
||||
if let Ok(mut src) =
|
||||
self.tcx.sess.source_map().span_to_snippet(attr.span)
|
||||
{
|
||||
|
|
|
@ -169,7 +169,7 @@ impl<'tcx> ReachableContext<'tcx> {
|
|||
if generics.requires_monomorphization(self.tcx) || attrs.requests_inline() {
|
||||
true
|
||||
} else {
|
||||
let impl_did = self.tcx.hir().get_parent_did(hir_id);
|
||||
let impl_did = self.tcx.hir().get_parent_item(hir_id);
|
||||
// Check the impl. If the generics on the self
|
||||
// type of the impl require inlining, this method
|
||||
// does too.
|
||||
|
|
|
@ -629,7 +629,7 @@ impl<'tcx> Visitor<'tcx> for MissingStabilityAnnotations<'tcx> {
|
|||
}
|
||||
|
||||
fn visit_impl_item(&mut self, ii: &'tcx hir::ImplItem<'tcx>) {
|
||||
let impl_def_id = self.tcx.hir().local_def_id(self.tcx.hir().get_parent_item(ii.hir_id()));
|
||||
let impl_def_id = self.tcx.hir().get_parent_item(ii.hir_id());
|
||||
if self.tcx.impl_trait_ref(impl_def_id).is_none() {
|
||||
self.check_missing_stability(ii.def_id, ii.span);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue