mirror of
https://github.com/rust-lang/rust.git
synced 2025-01-21 20:23:21 +00:00
Only store a LocalDefId in hir::TraitItem.
This commit is contained in:
parent
cebbba081e
commit
a871a0f111
@ -92,7 +92,7 @@ impl<'a> Visitor<'a> for ItemLowerer<'a, '_, '_> {
|
||||
self.lctx.with_hir_id_owner(item.id, |lctx| match ctxt {
|
||||
AssocCtxt::Trait => {
|
||||
let hir_item = lctx.lower_trait_item(item);
|
||||
let id = hir::TraitItemId { hir_id: hir_item.hir_id };
|
||||
let id = hir_item.trait_item_id();
|
||||
lctx.trait_items.insert(id, hir_item);
|
||||
lctx.modules.get_mut(&lctx.current_module).unwrap().trait_items.insert(id);
|
||||
}
|
||||
@ -846,7 +846,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
|
||||
};
|
||||
|
||||
hir::TraitItem {
|
||||
hir_id: self.lower_node_id(i.id),
|
||||
def_id: trait_item_def_id,
|
||||
ident: i.ident,
|
||||
attrs: self.lower_attrs(&i.attrs),
|
||||
generics,
|
||||
@ -866,7 +866,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
|
||||
}
|
||||
AssocItemKind::MacCall(..) => unimplemented!(),
|
||||
};
|
||||
let id = hir::TraitItemId { hir_id: self.lower_node_id(i.id) };
|
||||
let id = hir::TraitItemId { def_id: self.lower_node_id(i.id).expect_owner() };
|
||||
let defaultness = hir::Defaultness::Default { has_value: has_default };
|
||||
hir::TraitItemRef { id, ident: i.ident, span: i.span, defaultness, kind }
|
||||
}
|
||||
|
@ -1907,7 +1907,14 @@ pub struct FnSig<'hir> {
|
||||
// so it can fetched later.
|
||||
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Encodable, Debug)]
|
||||
pub struct TraitItemId {
|
||||
pub hir_id: HirId,
|
||||
pub def_id: LocalDefId,
|
||||
}
|
||||
|
||||
impl TraitItemId {
|
||||
pub fn hir_id(&self) -> HirId {
|
||||
// Items are always HIR owners.
|
||||
HirId::make_owner(self.def_id)
|
||||
}
|
||||
}
|
||||
|
||||
/// Represents an item declaration within a trait declaration,
|
||||
@ -1917,13 +1924,24 @@ pub struct TraitItemId {
|
||||
#[derive(Debug)]
|
||||
pub struct TraitItem<'hir> {
|
||||
pub ident: Ident,
|
||||
pub hir_id: HirId,
|
||||
pub def_id: LocalDefId,
|
||||
pub attrs: &'hir [Attribute],
|
||||
pub generics: Generics<'hir>,
|
||||
pub kind: TraitItemKind<'hir>,
|
||||
pub span: Span,
|
||||
}
|
||||
|
||||
impl TraitItem<'_> {
|
||||
pub fn hir_id(&self) -> HirId {
|
||||
// Items are always HIR owners.
|
||||
HirId::make_owner(self.def_id)
|
||||
}
|
||||
|
||||
pub fn trait_item_id(&self) -> TraitItemId {
|
||||
TraitItemId { def_id: self.def_id }
|
||||
}
|
||||
}
|
||||
|
||||
/// Represents a trait method's body (or just argument names).
|
||||
#[derive(Encodable, Debug, HashStable_Generic)]
|
||||
pub enum TraitFn<'hir> {
|
||||
@ -2885,9 +2903,10 @@ impl<'hir> Node<'hir> {
|
||||
|
||||
pub fn hir_id(&self) -> Option<HirId> {
|
||||
match self {
|
||||
Node::Item(Item { def_id, .. }) => Some(HirId::make_owner(*def_id)),
|
||||
Node::Item(Item { def_id, .. }) | Node::TraitItem(TraitItem { def_id, .. }) => {
|
||||
Some(HirId::make_owner(*def_id))
|
||||
}
|
||||
Node::ForeignItem(ForeignItem { hir_id, .. })
|
||||
| Node::TraitItem(TraitItem { hir_id, .. })
|
||||
| Node::ImplItem(ImplItem { hir_id, .. })
|
||||
| Node::Field(StructField { hir_id, .. })
|
||||
| Node::AnonConst(AnonConst { hir_id, .. })
|
||||
@ -2922,7 +2941,7 @@ mod size_asserts {
|
||||
rustc_data_structures::static_assert_size!(super::Ty<'static>, 72);
|
||||
|
||||
rustc_data_structures::static_assert_size!(super::Item<'static>, 200);
|
||||
rustc_data_structures::static_assert_size!(super::TraitItem<'static>, 152);
|
||||
rustc_data_structures::static_assert_size!(super::TraitItem<'static>, 144);
|
||||
rustc_data_structures::static_assert_size!(super::ImplItem<'static>, 168);
|
||||
rustc_data_structures::static_assert_size!(super::ForeignItem<'static>, 160);
|
||||
}
|
||||
|
@ -964,12 +964,12 @@ pub fn walk_trait_item<'v, V: Visitor<'v>>(visitor: &mut V, trait_item: &'v Trai
|
||||
visitor.visit_generics(&trait_item.generics);
|
||||
match trait_item.kind {
|
||||
TraitItemKind::Const(ref ty, default) => {
|
||||
visitor.visit_id(trait_item.hir_id);
|
||||
visitor.visit_id(trait_item.hir_id());
|
||||
visitor.visit_ty(ty);
|
||||
walk_list!(visitor, visit_nested_body, default);
|
||||
}
|
||||
TraitItemKind::Fn(ref sig, TraitFn::Required(param_names)) => {
|
||||
visitor.visit_id(trait_item.hir_id);
|
||||
visitor.visit_id(trait_item.hir_id());
|
||||
visitor.visit_fn_decl(&sig.decl);
|
||||
for ¶m_name in param_names {
|
||||
visitor.visit_ident(param_name);
|
||||
@ -981,11 +981,11 @@ pub fn walk_trait_item<'v, V: Visitor<'v>>(visitor: &mut V, trait_item: &'v Trai
|
||||
&sig.decl,
|
||||
body_id,
|
||||
trait_item.span,
|
||||
trait_item.hir_id,
|
||||
trait_item.hir_id(),
|
||||
);
|
||||
}
|
||||
TraitItemKind::Type(bounds, ref default) => {
|
||||
visitor.visit_id(trait_item.hir_id);
|
||||
visitor.visit_id(trait_item.hir_id());
|
||||
walk_list!(visitor, visit_param_bound, bounds);
|
||||
walk_list!(visitor, visit_ty, default);
|
||||
}
|
||||
|
@ -44,11 +44,11 @@ impl<HirCtx: crate::HashStableContext> ToStableHashKey<HirCtx> for ItemId {
|
||||
}
|
||||
|
||||
impl<HirCtx: crate::HashStableContext> ToStableHashKey<HirCtx> for TraitItemId {
|
||||
type KeyType = (DefPathHash, ItemLocalId);
|
||||
type KeyType = DefPathHash;
|
||||
|
||||
#[inline]
|
||||
fn to_stable_hash_key(&self, hcx: &HirCtx) -> (DefPathHash, ItemLocalId) {
|
||||
self.hir_id.to_stable_hash_key(hcx)
|
||||
fn to_stable_hash_key(&self, hcx: &HirCtx) -> DefPathHash {
|
||||
hcx.local_def_path_hash(self.def_id)
|
||||
}
|
||||
}
|
||||
|
||||
@ -109,7 +109,7 @@ impl<HirCtx: crate::HashStableContext> HashStable<HirCtx> for ImplItemId {
|
||||
|
||||
impl<HirCtx: crate::HashStableContext> HashStable<HirCtx> for TraitItemId {
|
||||
fn hash_stable(&self, hcx: &mut HirCtx, hasher: &mut StableHasher) {
|
||||
hcx.hash_reference_to_item(self.hir_id, hasher)
|
||||
hcx.hash_reference_to_item(self.hir_id(), hasher)
|
||||
}
|
||||
}
|
||||
|
||||
@ -139,7 +139,7 @@ impl<HirCtx: crate::HashStableContext> HashStable<HirCtx> for VisibilityKind<'_>
|
||||
|
||||
impl<HirCtx: crate::HashStableContext> HashStable<HirCtx> for TraitItem<'_> {
|
||||
fn hash_stable(&self, hcx: &mut HirCtx, hasher: &mut StableHasher) {
|
||||
let TraitItem { hir_id: _, ident, ref attrs, ref generics, ref kind, span } = *self;
|
||||
let TraitItem { def_id: _, ident, ref attrs, ref generics, ref kind, span } = *self;
|
||||
|
||||
hcx.hash_hir_item_like(|hcx| {
|
||||
ident.name.hash_stable(hcx, hasher);
|
||||
|
@ -934,7 +934,7 @@ impl<'a> State<'a> {
|
||||
}
|
||||
|
||||
pub fn print_trait_item(&mut self, ti: &hir::TraitItem<'_>) {
|
||||
self.ann.pre(self, AnnNode::SubItem(ti.hir_id));
|
||||
self.ann.pre(self, AnnNode::SubItem(ti.hir_id()));
|
||||
self.hardbreak_if_not_bol();
|
||||
self.maybe_print_comment(ti.span.lo());
|
||||
self.print_outer_attributes(&ti.attrs);
|
||||
@ -969,7 +969,7 @@ impl<'a> State<'a> {
|
||||
);
|
||||
}
|
||||
}
|
||||
self.ann.post(self, AnnNode::SubItem(ti.hir_id))
|
||||
self.ann.post(self, AnnNode::SubItem(ti.hir_id()))
|
||||
}
|
||||
|
||||
pub fn print_impl_item(&mut self, ii: &hir::ImplItem<'_>) {
|
||||
|
@ -172,7 +172,7 @@ impl Visitor<'tcx> for IfThisChanged<'tcx> {
|
||||
}
|
||||
|
||||
fn visit_trait_item(&mut self, trait_item: &'tcx hir::TraitItem<'tcx>) {
|
||||
self.process_attrs(trait_item.hir_id, &trait_item.attrs);
|
||||
self.process_attrs(trait_item.hir_id(), &trait_item.attrs);
|
||||
intravisit::walk_trait_item(self, trait_item);
|
||||
}
|
||||
|
||||
|
@ -454,7 +454,7 @@ impl ItemLikeVisitor<'tcx> for DirtyCleanVisitor<'tcx> {
|
||||
}
|
||||
|
||||
fn visit_trait_item(&mut self, item: &hir::TraitItem<'_>) {
|
||||
self.check_item(item.hir_id, item.span);
|
||||
self.check_item(item.hir_id(), item.span);
|
||||
}
|
||||
|
||||
fn visit_impl_item(&mut self, item: &hir::ImplItem<'_>) {
|
||||
|
@ -8,8 +8,7 @@ use rustc_errors::{struct_span_err, Applicability, DiagnosticBuilder, ErrorRepor
|
||||
use rustc_hir::def_id::DefId;
|
||||
use rustc_hir::intravisit::{walk_ty, ErasedMap, NestedVisitorMap, Visitor};
|
||||
use rustc_hir::{
|
||||
self as hir, GenericBound, ImplItem, Item, ItemKind, Lifetime, LifetimeName, Node, TraitItem,
|
||||
TyKind,
|
||||
self as hir, GenericBound, ImplItem, Item, ItemKind, Lifetime, LifetimeName, Node, TyKind,
|
||||
};
|
||||
use rustc_middle::ty::{self, AssocItemContainer, RegionKind, Ty, TypeFoldable, TypeVisitor};
|
||||
use rustc_span::symbol::Ident;
|
||||
@ -352,8 +351,8 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
Some(Node::TraitItem(TraitItem { ident, hir_id, .. })) => {
|
||||
let parent_id = tcx.hir().get_parent_item(*hir_id);
|
||||
Some(Node::TraitItem(trait_item)) => {
|
||||
let parent_id = tcx.hir().get_parent_item(trait_item.hir_id());
|
||||
match tcx.hir().find(parent_id) {
|
||||
Some(Node::Item(Item { kind: ItemKind::Trait(..), .. })) => {
|
||||
// The method being called is defined in the `trait`, but the `'static`
|
||||
@ -389,7 +388,7 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
|
||||
})
|
||||
.next()
|
||||
{
|
||||
Some(self_ty) => Some((*ident, self_ty)),
|
||||
Some(self_ty) => Some((trait_item.ident, self_ty)),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
@ -586,7 +586,7 @@ impl<'tcx> LateLintPass<'tcx> for MissingDoc {
|
||||
if let hir::VisibilityKind::Inherited = it.vis.node {
|
||||
self.private_traits.insert(it.hir_id());
|
||||
for trait_item_ref in trait_item_refs {
|
||||
self.private_traits.insert(trait_item_ref.id.hir_id);
|
||||
self.private_traits.insert(trait_item_ref.id.hir_id());
|
||||
}
|
||||
return;
|
||||
}
|
||||
@ -626,16 +626,15 @@ impl<'tcx> LateLintPass<'tcx> for MissingDoc {
|
||||
}
|
||||
|
||||
fn check_trait_item(&mut self, cx: &LateContext<'_>, trait_item: &hir::TraitItem<'_>) {
|
||||
if self.private_traits.contains(&trait_item.hir_id) {
|
||||
if self.private_traits.contains(&trait_item.hir_id()) {
|
||||
return;
|
||||
}
|
||||
|
||||
let def_id = cx.tcx.hir().local_def_id(trait_item.hir_id);
|
||||
let (article, desc) = cx.tcx.article_and_description(def_id.to_def_id());
|
||||
let (article, desc) = cx.tcx.article_and_description(trait_item.def_id.to_def_id());
|
||||
|
||||
self.check_missing_docs_attrs(
|
||||
cx,
|
||||
Some(trait_item.hir_id),
|
||||
Some(trait_item.hir_id()),
|
||||
&trait_item.attrs,
|
||||
trait_item.span,
|
||||
article,
|
||||
|
@ -301,8 +301,8 @@ impl<'tcx, T: LateLintPass<'tcx>> hir_visit::Visitor<'tcx> for LateContextAndPas
|
||||
fn visit_trait_item(&mut self, trait_item: &'tcx hir::TraitItem<'tcx>) {
|
||||
let generics = self.context.generics.take();
|
||||
self.context.generics = Some(&trait_item.generics);
|
||||
self.with_lint_attrs(trait_item.hir_id, &trait_item.attrs, |cx| {
|
||||
cx.with_param_env(trait_item.hir_id, |cx| {
|
||||
self.with_lint_attrs(trait_item.hir_id(), &trait_item.attrs, |cx| {
|
||||
cx.with_param_env(trait_item.hir_id(), |cx| {
|
||||
lint_callback!(cx, check_trait_item, trait_item);
|
||||
hir_visit::walk_trait_item(cx, trait_item);
|
||||
lint_callback!(cx, check_trait_item_post, trait_item);
|
||||
|
@ -631,7 +631,7 @@ impl<'tcx> intravisit::Visitor<'tcx> for LintLevelMapBuilder<'_, 'tcx> {
|
||||
}
|
||||
|
||||
fn visit_trait_item(&mut self, trait_item: &'tcx hir::TraitItem<'tcx>) {
|
||||
self.with_lint_attrs(trait_item.hir_id, &trait_item.attrs, |builder| {
|
||||
self.with_lint_attrs(trait_item.hir_id(), &trait_item.attrs, |builder| {
|
||||
intravisit::walk_trait_item(builder, trait_item);
|
||||
});
|
||||
}
|
||||
|
@ -229,7 +229,7 @@ impl<'a> FnLikeNode<'a> {
|
||||
},
|
||||
Node::TraitItem(ti) => match ti.kind {
|
||||
hir::TraitItemKind::Fn(ref sig, hir::TraitFn::Provided(body)) => {
|
||||
method(ti.hir_id, ti.ident, sig, None, body, ti.span, &ti.attrs)
|
||||
method(ti.hir_id(), ti.ident, sig, None, body, ti.span, &ti.attrs)
|
||||
}
|
||||
_ => bug!("trait method FnLikeNode that is not fn-like"),
|
||||
},
|
||||
|
@ -391,14 +391,10 @@ impl<'a, 'hir> Visitor<'hir> for NodeCollector<'a, 'hir> {
|
||||
}
|
||||
|
||||
fn visit_trait_item(&mut self, ti: &'hir TraitItem<'hir>) {
|
||||
debug_assert_eq!(
|
||||
ti.hir_id.owner,
|
||||
self.definitions.opt_hir_id_to_local_def_id(ti.hir_id).unwrap()
|
||||
);
|
||||
self.with_dep_node_owner(ti.hir_id.owner, ti, |this, hash| {
|
||||
this.insert_with_hash(ti.span, ti.hir_id, Node::TraitItem(ti), hash);
|
||||
self.with_dep_node_owner(ti.def_id, ti, |this, hash| {
|
||||
this.insert_with_hash(ti.span, ti.hir_id(), Node::TraitItem(ti), hash);
|
||||
|
||||
this.with_parent(ti.hir_id, |this| {
|
||||
this.with_parent(ti.hir_id(), |this| {
|
||||
intravisit::walk_trait_item(this, ti);
|
||||
});
|
||||
});
|
||||
|
@ -308,7 +308,7 @@ impl<'hir> Map<'hir> {
|
||||
}
|
||||
|
||||
pub fn trait_item(&self, id: TraitItemId) -> &'hir TraitItem<'hir> {
|
||||
match self.find(id.hir_id).unwrap() {
|
||||
match self.find(id.hir_id()).unwrap() {
|
||||
Node::TraitItem(item) => item,
|
||||
_ => bug!(),
|
||||
}
|
||||
|
@ -816,7 +816,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 \
|
||||
|
@ -1081,7 +1081,13 @@ impl Visitor<'tcx> for CheckAttrVisitor<'tcx> {
|
||||
|
||||
fn visit_trait_item(&mut self, trait_item: &'tcx TraitItem<'tcx>) {
|
||||
let target = Target::from_trait_item(trait_item);
|
||||
self.check_attributes(trait_item.hir_id, &trait_item.attrs, &trait_item.span, target, None);
|
||||
self.check_attributes(
|
||||
trait_item.hir_id(),
|
||||
&trait_item.attrs,
|
||||
&trait_item.span,
|
||||
target,
|
||||
None,
|
||||
);
|
||||
intravisit::walk_trait_item(self, trait_item)
|
||||
}
|
||||
|
||||
|
@ -440,9 +440,9 @@ impl<'v, 'k, 'tcx> ItemLikeVisitor<'v> for LifeSeeder<'k, 'tcx> {
|
||||
fn visit_trait_item(&mut self, trait_item: &hir::TraitItem<'_>) {
|
||||
use hir::TraitItemKind::{Const, Fn};
|
||||
if matches!(trait_item.kind, Const(_, Some(_)) | Fn(_, hir::TraitFn::Provided(_)))
|
||||
&& has_allow_dead_code_or_lang_attr(self.tcx, trait_item.hir_id, &trait_item.attrs)
|
||||
&& has_allow_dead_code_or_lang_attr(self.tcx, trait_item.hir_id(), &trait_item.attrs)
|
||||
{
|
||||
self.worklist.push(trait_item.hir_id);
|
||||
self.worklist.push(trait_item.hir_id());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -31,7 +31,7 @@ impl<'v, 'tcx> ItemLikeVisitor<'v> for DiagnosticItemCollector<'tcx> {
|
||||
}
|
||||
|
||||
fn visit_trait_item(&mut self, trait_item: &hir::TraitItem<'_>) {
|
||||
self.observe_item(&trait_item.attrs, trait_item.hir_id);
|
||||
self.observe_item(&trait_item.attrs, trait_item.hir_id());
|
||||
}
|
||||
|
||||
fn visit_impl_item(&mut self, impl_item: &hir::ImplItem<'_>) {
|
||||
|
@ -61,7 +61,7 @@ impl<'a, 'hir> ItemLikeVisitor<'hir> for OuterVisitor<'a, 'hir> {
|
||||
|
||||
fn visit_trait_item(&mut self, i: &'hir hir::TraitItem<'hir>) {
|
||||
let mut inner_visitor = self.new_inner_visitor(self.hir_map);
|
||||
inner_visitor.check(i.hir_id, |this| intravisit::walk_trait_item(this, i));
|
||||
inner_visitor.check(i.hir_id(), |this| intravisit::walk_trait_item(this, i));
|
||||
}
|
||||
|
||||
fn visit_impl_item(&mut self, i: &'hir hir::ImplItem<'hir>) {
|
||||
|
@ -187,7 +187,7 @@ impl<'v> hir_visit::Visitor<'v> for StatCollector<'v> {
|
||||
}
|
||||
|
||||
fn visit_trait_item(&mut self, ti: &'v hir::TraitItem<'v>) {
|
||||
self.record("TraitItem", Id::Node(ti.hir_id), ti);
|
||||
self.record("TraitItem", Id::Node(ti.hir_id()), ti);
|
||||
hir_visit::walk_trait_item(self, ti)
|
||||
}
|
||||
|
||||
|
@ -42,7 +42,7 @@ impl ItemLikeVisitor<'v> for LanguageItemCollector<'tcx> {
|
||||
fn visit_trait_item(&mut self, trait_item: &hir::TraitItem<'_>) {
|
||||
self.check_for_lang(
|
||||
Target::from_trait_item(trait_item),
|
||||
trait_item.hir_id,
|
||||
trait_item.hir_id(),
|
||||
trait_item.attrs,
|
||||
)
|
||||
}
|
||||
|
@ -389,7 +389,7 @@ impl<'a, 'tcx> Visitor<'tcx> for Annotator<'a, 'tcx> {
|
||||
|
||||
fn visit_trait_item(&mut self, ti: &'tcx hir::TraitItem<'tcx>) {
|
||||
self.annotate(
|
||||
ti.hir_id,
|
||||
ti.hir_id(),
|
||||
&ti.attrs,
|
||||
ti.span,
|
||||
AnnotationKind::Required,
|
||||
@ -571,7 +571,7 @@ impl<'tcx> Visitor<'tcx> for MissingStabilityAnnotations<'tcx> {
|
||||
}
|
||||
|
||||
fn visit_trait_item(&mut self, ti: &'tcx hir::TraitItem<'tcx>) {
|
||||
self.check_missing_stability(ti.hir_id, ti.span);
|
||||
self.check_missing_stability(ti.hir_id(), ti.span);
|
||||
intravisit::walk_trait_item(self, ti);
|
||||
}
|
||||
|
||||
|
@ -669,7 +669,7 @@ impl Visitor<'tcx> for EmbargoVisitor<'tcx> {
|
||||
}
|
||||
hir::ItemKind::Trait(.., trait_item_refs) => {
|
||||
for trait_item_ref in trait_item_refs {
|
||||
self.update(trait_item_ref.id.hir_id, item_level);
|
||||
self.update(trait_item_ref.id.hir_id(), item_level);
|
||||
}
|
||||
}
|
||||
hir::ItemKind::Struct(ref def, _) | hir::ItemKind::Union(ref def, _) => {
|
||||
@ -745,7 +745,7 @@ impl Visitor<'tcx> for EmbargoVisitor<'tcx> {
|
||||
self.reach(item.hir_id(), item_level).generics().predicates();
|
||||
|
||||
for trait_item_ref in trait_item_refs {
|
||||
let mut reach = self.reach(trait_item_ref.id.hir_id, item_level);
|
||||
let mut reach = self.reach(trait_item_ref.id.hir_id(), item_level);
|
||||
reach.generics().predicates();
|
||||
|
||||
if trait_item_ref.kind == AssocItemKind::Type
|
||||
@ -1954,14 +1954,14 @@ impl<'a, 'tcx> Visitor<'tcx> for PrivateItemsInPublicInterfacesVisitor<'a, 'tcx>
|
||||
|
||||
for trait_item_ref in trait_item_refs {
|
||||
self.check_assoc_item(
|
||||
trait_item_ref.id.hir_id,
|
||||
trait_item_ref.id.hir_id(),
|
||||
trait_item_ref.kind,
|
||||
trait_item_ref.defaultness,
|
||||
item_visibility,
|
||||
);
|
||||
|
||||
if let AssocItemKind::Type = trait_item_ref.kind {
|
||||
self.check(trait_item_ref.id.hir_id, item_visibility).bounds();
|
||||
self.check(trait_item_ref.id.hir_id(), item_visibility).bounds();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -635,7 +635,8 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> {
|
||||
let parent_item_id =
|
||||
hir::ItemId { def_id: parent_id.expect_owner() };
|
||||
let parent_impl_id = hir::ImplItemId { hir_id: parent_id };
|
||||
let parent_trait_id = hir::TraitItemId { hir_id: parent_id };
|
||||
let parent_trait_id =
|
||||
hir::TraitItemId { def_id: parent_id.expect_owner() };
|
||||
let krate = self.tcx.hir().krate();
|
||||
|
||||
if !(krate.items.contains_key(&parent_item_id)
|
||||
@ -740,7 +741,7 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> {
|
||||
self.missing_named_lifetime_spots.push((&trait_item.generics).into());
|
||||
let tcx = self.tcx;
|
||||
self.visit_early_late(
|
||||
Some(tcx.hir().get_parent_item(trait_item.hir_id)),
|
||||
Some(tcx.hir().get_parent_item(trait_item.hir_id())),
|
||||
&sig.decl,
|
||||
&trait_item.generics,
|
||||
|this| intravisit::walk_trait_item(this, trait_item),
|
||||
@ -2113,7 +2114,7 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
|
||||
self.tcx.hir().expect_item(self.tcx.hir().get_parent_item(parent)).kind
|
||||
{
|
||||
assoc_item_kind =
|
||||
trait_items.iter().find(|ti| ti.id.hir_id == parent).map(|ti| ti.kind);
|
||||
trait_items.iter().find(|ti| ti.id.hir_id() == parent).map(|ti| ti.kind);
|
||||
}
|
||||
match *m {
|
||||
hir::TraitFn::Required(_) => None,
|
||||
|
@ -674,7 +674,7 @@ impl<'tcx> DumpVisitor<'tcx> {
|
||||
let id = id_from_def_id(item.def_id.to_def_id());
|
||||
let span = self.span_from_span(item.ident.span);
|
||||
let children =
|
||||
methods.iter().map(|i| id_from_hir_id(i.id.hir_id, &self.save_ctxt)).collect();
|
||||
methods.iter().map(|i| id_from_def_id(i.id.def_id.to_def_id())).collect();
|
||||
self.dumper.dump_def(
|
||||
&access_from!(self.save_ctxt, item, item.hir_id()),
|
||||
Def {
|
||||
@ -999,7 +999,7 @@ impl<'tcx> DumpVisitor<'tcx> {
|
||||
let body = body.map(|b| &self.tcx.hir().body(b).value);
|
||||
let respan = respan(vis_span, hir::VisibilityKind::Public);
|
||||
self.process_assoc_const(
|
||||
trait_item.hir_id,
|
||||
trait_item.hir_id(),
|
||||
trait_item.ident,
|
||||
&ty,
|
||||
body,
|
||||
@ -1015,7 +1015,7 @@ impl<'tcx> DumpVisitor<'tcx> {
|
||||
self.process_method(
|
||||
sig,
|
||||
body,
|
||||
trait_item.hir_id,
|
||||
trait_item.hir_id(),
|
||||
trait_item.ident,
|
||||
&trait_item.generics,
|
||||
&respan,
|
||||
@ -1025,15 +1025,12 @@ impl<'tcx> DumpVisitor<'tcx> {
|
||||
hir::TraitItemKind::Type(ref bounds, ref default_ty) => {
|
||||
// FIXME do something with _bounds (for type refs)
|
||||
let name = trait_item.ident.name.to_string();
|
||||
let qualname = format!(
|
||||
"::{}",
|
||||
self.tcx
|
||||
.def_path_str(self.tcx.hir().local_def_id(trait_item.hir_id).to_def_id())
|
||||
);
|
||||
let qualname =
|
||||
format!("::{}", self.tcx.def_path_str(trait_item.def_id.to_def_id()));
|
||||
|
||||
if !self.span.filter_generated(trait_item.ident.span) {
|
||||
let span = self.span_from_span(trait_item.ident.span);
|
||||
let id = id_from_hir_id(trait_item.hir_id, &self.save_ctxt);
|
||||
let id = id_from_def_id(trait_item.def_id.to_def_id());
|
||||
|
||||
self.dumper.dump_def(
|
||||
&Access { public: true, reachable: true },
|
||||
@ -1049,7 +1046,7 @@ impl<'tcx> DumpVisitor<'tcx> {
|
||||
decl_id: None,
|
||||
docs: self.save_ctxt.docs_for_attrs(&trait_item.attrs),
|
||||
sig: sig::assoc_type_signature(
|
||||
trait_item.hir_id,
|
||||
trait_item.hir_id(),
|
||||
trait_item.ident,
|
||||
Some(bounds),
|
||||
default_ty.as_ref().map(|ty| &**ty),
|
||||
|
@ -65,7 +65,7 @@ impl hir::itemlikevisit::ItemLikeVisitor<'tcx> for SymbolNamesTest<'tcx> {
|
||||
}
|
||||
|
||||
fn visit_trait_item(&mut self, trait_item: &'tcx hir::TraitItem<'tcx>) {
|
||||
self.process_attrs(trait_item.hir_id);
|
||||
self.process_attrs(trait_item.hir_id());
|
||||
}
|
||||
|
||||
fn visit_impl_item(&mut self, impl_item: &'tcx hir::ImplItem<'tcx>) {
|
||||
|
@ -82,7 +82,7 @@ fn associated_item_from_trait_item_ref(
|
||||
parent_def_id: LocalDefId,
|
||||
trait_item_ref: &hir::TraitItemRef,
|
||||
) -> ty::AssocItem {
|
||||
let def_id = tcx.hir().local_def_id(trait_item_ref.id.hir_id);
|
||||
let def_id = trait_item_ref.id.def_id;
|
||||
let (kind, has_self) = match trait_item_ref.kind {
|
||||
hir::AssocItemKind::Const => (ty::AssocKind::Const, false),
|
||||
hir::AssocItemKind::Fn { has_self } => (ty::AssocKind::Fn, has_self),
|
||||
@ -139,7 +139,9 @@ fn associated_item(tcx: TyCtxt<'_>, def_id: DefId) -> ty::AssocItem {
|
||||
}
|
||||
|
||||
hir::ItemKind::Trait(.., ref trait_item_refs) => {
|
||||
if let Some(trait_item_ref) = trait_item_refs.iter().find(|i| i.id.hir_id == id) {
|
||||
if let Some(trait_item_ref) =
|
||||
trait_item_refs.iter().find(|i| i.id.def_id.to_def_id() == def_id)
|
||||
{
|
||||
let assoc_item =
|
||||
associated_item_from_trait_item_ref(tcx, parent_def_id, trait_item_ref);
|
||||
debug_assert_eq!(assoc_item.def_id, def_id);
|
||||
@ -196,10 +198,7 @@ fn associated_item_def_ids(tcx: TyCtxt<'_>, def_id: DefId) -> &[DefId] {
|
||||
let item = tcx.hir().expect_item(id);
|
||||
match item.kind {
|
||||
hir::ItemKind::Trait(.., ref trait_item_refs) => tcx.arena.alloc_from_iter(
|
||||
trait_item_refs
|
||||
.iter()
|
||||
.map(|trait_item_ref| trait_item_ref.id)
|
||||
.map(|id| tcx.hir().local_def_id(id.hir_id).to_def_id()),
|
||||
trait_item_refs.iter().map(|trait_item_ref| trait_item_ref.id.def_id.to_def_id()),
|
||||
),
|
||||
hir::ItemKind::Impl(ref impl_) => tcx.arena.alloc_from_iter(
|
||||
impl_
|
||||
|
@ -725,8 +725,7 @@ pub fn check_item_type<'tcx>(tcx: TyCtxt<'tcx>, it: &'tcx hir::Item<'tcx>) {
|
||||
fn_maybe_err(tcx, item.ident.span, abi);
|
||||
}
|
||||
hir::TraitItemKind::Type(.., Some(_default)) => {
|
||||
let item_def_id = tcx.hir().local_def_id(item.hir_id).to_def_id();
|
||||
let assoc_item = tcx.associated_item(item_def_id);
|
||||
let assoc_item = tcx.associated_item(item.def_id);
|
||||
let trait_substs =
|
||||
InternalSubsts::identity_for_item(tcx, it.def_id.to_def_id());
|
||||
let _: Result<_, rustc_errors::ErrorReported> = check_type_bounds(
|
||||
|
@ -823,8 +823,8 @@ fn compare_synthetic_generics<'tcx>(
|
||||
// FIXME: this is obviously suboptimal since the name can already be used
|
||||
// as another generic argument
|
||||
let new_name = tcx.sess.source_map().span_to_snippet(trait_span).ok()?;
|
||||
let trait_m = tcx.hir().local_def_id_to_hir_id(trait_m.def_id.as_local()?);
|
||||
let trait_m = tcx.hir().trait_item(hir::TraitItemId { hir_id: trait_m });
|
||||
let trait_m = trait_m.def_id.as_local()?;
|
||||
let trait_m = tcx.hir().trait_item(hir::TraitItemId { def_id: trait_m });
|
||||
|
||||
let impl_m = tcx.hir().local_def_id_to_hir_id(impl_m.def_id.as_local()?);
|
||||
let impl_m = tcx.hir().impl_item(hir::ImplItemId { hir_id: impl_m });
|
||||
|
@ -197,7 +197,7 @@ pub fn check_trait_item(tcx: TyCtxt<'_>, def_id: LocalDefId) {
|
||||
_ => None,
|
||||
};
|
||||
check_object_unsafe_self_trait_by_name(tcx, &trait_item);
|
||||
check_associated_item(tcx, trait_item.hir_id, trait_item.span, method_sig);
|
||||
check_associated_item(tcx, trait_item.hir_id(), trait_item.span, method_sig);
|
||||
}
|
||||
|
||||
fn could_be_self(trait_def_id: LocalDefId, ty: &hir::Ty<'_>) -> bool {
|
||||
@ -213,7 +213,7 @@ fn could_be_self(trait_def_id: LocalDefId, ty: &hir::Ty<'_>) -> bool {
|
||||
/// Detect when an object unsafe trait is referring to itself in one of its associated items.
|
||||
/// When this is done, suggest using `Self` instead.
|
||||
fn check_object_unsafe_self_trait_by_name(tcx: TyCtxt<'_>, item: &hir::TraitItem<'_>) {
|
||||
let (trait_name, trait_def_id) = match tcx.hir().get(tcx.hir().get_parent_item(item.hir_id)) {
|
||||
let (trait_name, trait_def_id) = match tcx.hir().get(tcx.hir().get_parent_item(item.hir_id())) {
|
||||
hir::Node::Item(item) => match item.kind {
|
||||
hir::ItemKind::Trait(..) => (item.ident, item.def_id),
|
||||
_ => return,
|
||||
@ -1354,8 +1354,7 @@ impl Visitor<'tcx> for CheckTypeWellFormedVisitor<'tcx> {
|
||||
|
||||
fn visit_trait_item(&mut self, trait_item: &'tcx hir::TraitItem<'tcx>) {
|
||||
debug!("visit_trait_item: {:?}", trait_item);
|
||||
let def_id = self.tcx.hir().local_def_id(trait_item.hir_id);
|
||||
self.tcx.ensure().check_trait_item_well_formed(def_id);
|
||||
self.tcx.ensure().check_trait_item_well_formed(trait_item.def_id);
|
||||
hir_visit::walk_trait_item(self, trait_item);
|
||||
}
|
||||
|
||||
|
@ -281,7 +281,7 @@ impl Visitor<'tcx> for CollectItemTypesVisitor<'tcx> {
|
||||
}
|
||||
|
||||
fn visit_trait_item(&mut self, trait_item: &'tcx hir::TraitItem<'tcx>) {
|
||||
convert_trait_item(self.tcx, trait_item.hir_id);
|
||||
convert_trait_item(self.tcx, trait_item.trait_item_id());
|
||||
intravisit::walk_trait_item(self, trait_item);
|
||||
}
|
||||
|
||||
@ -804,23 +804,22 @@ fn convert_item(tcx: TyCtxt<'_>, item_id: hir::ItemId) {
|
||||
}
|
||||
}
|
||||
|
||||
fn convert_trait_item(tcx: TyCtxt<'_>, trait_item_id: hir::HirId) {
|
||||
let trait_item = tcx.hir().expect_trait_item(trait_item_id);
|
||||
let def_id = tcx.hir().local_def_id(trait_item.hir_id);
|
||||
tcx.ensure().generics_of(def_id);
|
||||
fn convert_trait_item(tcx: TyCtxt<'_>, trait_item_id: hir::TraitItemId) {
|
||||
let trait_item = tcx.hir().trait_item(trait_item_id);
|
||||
tcx.ensure().generics_of(trait_item_id.def_id);
|
||||
|
||||
match trait_item.kind {
|
||||
hir::TraitItemKind::Fn(..) => {
|
||||
tcx.ensure().type_of(def_id);
|
||||
tcx.ensure().fn_sig(def_id);
|
||||
tcx.ensure().type_of(trait_item_id.def_id);
|
||||
tcx.ensure().fn_sig(trait_item_id.def_id);
|
||||
}
|
||||
|
||||
hir::TraitItemKind::Const(.., Some(_)) => {
|
||||
tcx.ensure().type_of(def_id);
|
||||
tcx.ensure().type_of(trait_item_id.def_id);
|
||||
}
|
||||
|
||||
hir::TraitItemKind::Const(..) => {
|
||||
tcx.ensure().type_of(def_id);
|
||||
tcx.ensure().type_of(trait_item_id.def_id);
|
||||
// Account for `const C: _;`.
|
||||
let mut visitor = PlaceholderHirTyCollector::default();
|
||||
visitor.visit_trait_item(trait_item);
|
||||
@ -828,8 +827,8 @@ fn convert_trait_item(tcx: TyCtxt<'_>, trait_item_id: hir::HirId) {
|
||||
}
|
||||
|
||||
hir::TraitItemKind::Type(_, Some(_)) => {
|
||||
tcx.ensure().item_bounds(def_id);
|
||||
tcx.ensure().type_of(def_id);
|
||||
tcx.ensure().item_bounds(trait_item_id.def_id);
|
||||
tcx.ensure().type_of(trait_item_id.def_id);
|
||||
// Account for `type T = _;`.
|
||||
let mut visitor = PlaceholderHirTyCollector::default();
|
||||
visitor.visit_trait_item(trait_item);
|
||||
@ -837,7 +836,7 @@ fn convert_trait_item(tcx: TyCtxt<'_>, trait_item_id: hir::HirId) {
|
||||
}
|
||||
|
||||
hir::TraitItemKind::Type(_, None) => {
|
||||
tcx.ensure().item_bounds(def_id);
|
||||
tcx.ensure().item_bounds(trait_item_id.def_id);
|
||||
// #74612: Visit and try to find bad placeholders
|
||||
// even if there is no concrete type.
|
||||
let mut visitor = PlaceholderHirTyCollector::default();
|
||||
@ -847,7 +846,7 @@ fn convert_trait_item(tcx: TyCtxt<'_>, trait_item_id: hir::HirId) {
|
||||
}
|
||||
};
|
||||
|
||||
tcx.ensure().predicates_of(def_id);
|
||||
tcx.ensure().predicates_of(trait_item_id.def_id);
|
||||
}
|
||||
|
||||
fn convert_impl_item(tcx: TyCtxt<'_>, impl_item_id: hir::HirId) {
|
||||
|
@ -599,8 +599,7 @@ fn find_opaque_ty_constraints(tcx: TyCtxt<'_>, def_id: LocalDefId) -> Ty<'_> {
|
||||
}
|
||||
fn visit_trait_item(&mut self, it: &'tcx TraitItem<'tcx>) {
|
||||
debug!("find_existential_constraints: visiting {:?}", it);
|
||||
let def_id = self.tcx.hir().local_def_id(it.hir_id);
|
||||
self.check(def_id);
|
||||
self.check(it.def_id);
|
||||
intravisit::walk_trait_item(self, it);
|
||||
}
|
||||
}
|
||||
|
@ -98,7 +98,7 @@ impl<'a, 'tcx, 'v> ItemLikeVisitor<'v> for ConstraintContext<'a, 'tcx> {
|
||||
|
||||
fn visit_trait_item(&mut self, trait_item: &hir::TraitItem<'_>) {
|
||||
if let hir::TraitItemKind::Fn(..) = trait_item.kind {
|
||||
self.visit_node_helper(trait_item.hir_id);
|
||||
self.visit_node_helper(trait_item.hir_id());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -159,7 +159,7 @@ impl<'a, 'tcx, 'v> ItemLikeVisitor<'v> for TermsContext<'a, 'tcx> {
|
||||
|
||||
fn visit_trait_item(&mut self, trait_item: &hir::TraitItem<'_>) {
|
||||
if let hir::TraitItemKind::Fn(..) = trait_item.kind {
|
||||
self.add_inferreds_for_item(trait_item.hir_id);
|
||||
self.add_inferreds_for_item(trait_item.hir_id());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1044,7 +1044,7 @@ impl Clean<TypeKind> for hir::def::DefKind {
|
||||
|
||||
impl Clean<Item> for hir::TraitItem<'_> {
|
||||
fn clean(&self, cx: &DocContext<'_>) -> Item {
|
||||
let local_did = cx.tcx.hir().local_def_id(self.hir_id).to_def_id();
|
||||
let local_did = self.def_id.to_def_id();
|
||||
cx.with_param_env(local_did, || {
|
||||
let inner = match self.kind {
|
||||
hir::TraitItemKind::Const(ref ty, default) => {
|
||||
|
@ -1056,9 +1056,15 @@ impl<'a, 'hir, 'tcx> intravisit::Visitor<'hir> for HirCollector<'a, 'hir, 'tcx>
|
||||
}
|
||||
|
||||
fn visit_trait_item(&mut self, item: &'hir hir::TraitItem<'_>) {
|
||||
self.visit_testable(item.ident.to_string(), &item.attrs, item.hir_id, item.span, |this| {
|
||||
intravisit::walk_trait_item(this, item);
|
||||
});
|
||||
self.visit_testable(
|
||||
item.ident.to_string(),
|
||||
&item.attrs,
|
||||
item.hir_id(),
|
||||
item.span,
|
||||
|this| {
|
||||
intravisit::walk_trait_item(this, item);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
fn visit_impl_item(&mut self, item: &'hir hir::ImplItem<'_>) {
|
||||
|
@ -246,7 +246,7 @@ impl<'tcx> LateLintPass<'tcx> for DocMarkdown {
|
||||
let headers = check_attrs(cx, &self.valid_idents, &item.attrs);
|
||||
if let hir::TraitItemKind::Fn(ref sig, ..) = item.kind {
|
||||
if !in_external_macro(cx.tcx.sess, item.span) {
|
||||
lint_for_missing_headers(cx, item.hir_id, item.span, sig, headers, None, None);
|
||||
lint_for_missing_headers(cx, item.hir_id(), item.span, sig, headers, None, None);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -87,11 +87,11 @@ impl<'tcx> LateLintPass<'tcx> for BoxedLocal {
|
||||
// find `self` ty for this trait if relevant
|
||||
if let ItemKind::Trait(_, _, _, _, items) = item.kind {
|
||||
for trait_item in items {
|
||||
if trait_item.id.hir_id == hir_id {
|
||||
if trait_item.id.hir_id() == hir_id {
|
||||
// be sure we have `self` parameter in this function
|
||||
if let AssocItemKind::Fn { has_self: true } = trait_item.kind {
|
||||
trait_self_ty =
|
||||
Some(TraitRef::identity(cx.tcx, trait_item.id.hir_id.owner.to_def_id()).self_ty());
|
||||
Some(TraitRef::identity(cx.tcx, trait_item.id.def_id.to_def_id()).self_ty());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -339,7 +339,7 @@ impl<'tcx> LateLintPass<'tcx> for Functions {
|
||||
if sig.header.abi == Abi::Rust {
|
||||
self.check_arg_number(cx, &sig.decl, item.span.with_hi(sig.decl.output.span().hi()));
|
||||
}
|
||||
let is_public = cx.access_levels.is_exported(item.hir_id);
|
||||
let is_public = cx.access_levels.is_exported(item.hir_id());
|
||||
let fn_header_span = item.span.with_hi(sig.decl.output.span().hi());
|
||||
if is_public {
|
||||
check_result_unit_err(cx, &sig.decl, item.span, fn_header_span);
|
||||
@ -347,11 +347,11 @@ impl<'tcx> LateLintPass<'tcx> for Functions {
|
||||
|
||||
let attr = must_use_attr(&item.attrs);
|
||||
if let Some(attr) = attr {
|
||||
check_needless_must_use(cx, &sig.decl, item.hir_id, item.span, fn_header_span, attr);
|
||||
check_needless_must_use(cx, &sig.decl, item.hir_id(), item.span, fn_header_span, attr);
|
||||
}
|
||||
if let hir::TraitFn::Provided(eid) = *eid {
|
||||
let body = cx.tcx.hir().body(eid);
|
||||
Self::check_raw_ptr(cx, sig.header.unsafety, &sig.decl, body, item.hir_id);
|
||||
Self::check_raw_ptr(cx, sig.header.unsafety, &sig.decl, body, item.hir_id());
|
||||
|
||||
if attr.is_none() && is_public && !is_proc_macro(cx.sess(), &item.attrs) {
|
||||
check_must_use_candidate(
|
||||
@ -359,7 +359,7 @@ impl<'tcx> LateLintPass<'tcx> for Functions {
|
||||
&sig.decl,
|
||||
body,
|
||||
item.span,
|
||||
item.hir_id,
|
||||
item.hir_id(),
|
||||
item.span.with_hi(sig.decl.output.span().hi()),
|
||||
"this method could have a `#[must_use]` attribute",
|
||||
);
|
||||
|
@ -159,10 +159,7 @@ fn check_trait_items(cx: &LateContext<'_>, visited_trait: &Item<'_>, trait_items
|
||||
fn is_named_self(cx: &LateContext<'_>, item: &TraitItemRef, name: &str) -> bool {
|
||||
item.ident.name.as_str() == name
|
||||
&& if let AssocItemKind::Fn { has_self } = item.kind {
|
||||
has_self && {
|
||||
let did = cx.tcx.hir().local_def_id(item.id.hir_id);
|
||||
cx.tcx.fn_sig(did).inputs().skip_binder().len() == 1
|
||||
}
|
||||
has_self && { cx.tcx.fn_sig(item.id.def_id).inputs().skip_binder().len() == 1 }
|
||||
} else {
|
||||
false
|
||||
}
|
||||
|
@ -1791,7 +1791,7 @@ impl<'tcx> LateLintPass<'tcx> for Methods {
|
||||
if let Some(first_arg_ty) = sig.decl.inputs.iter().next();
|
||||
let first_arg_span = first_arg_ty.span;
|
||||
let first_arg_ty = hir_ty_to_ty(cx.tcx, first_arg_ty);
|
||||
let self_ty = TraitRef::identity(cx.tcx, item.hir_id.owner.to_def_id()).self_ty();
|
||||
let self_ty = TraitRef::identity(cx.tcx, item.def_id.to_def_id()).self_ty();
|
||||
|
||||
then {
|
||||
lint_wrong_self_convention(cx, &item.ident.name.as_str(), false, self_ty, first_arg_ty, first_arg_span);
|
||||
@ -1801,8 +1801,8 @@ impl<'tcx> LateLintPass<'tcx> for Methods {
|
||||
if_chain! {
|
||||
if item.ident.name == sym::new;
|
||||
if let TraitItemKind::Fn(_, _) = item.kind;
|
||||
let ret_ty = return_ty(cx, item.hir_id);
|
||||
let self_ty = TraitRef::identity(cx.tcx, item.hir_id.owner.to_def_id()).self_ty();
|
||||
let ret_ty = return_ty(cx, item.hir_id());
|
||||
let self_ty = TraitRef::identity(cx.tcx, item.def_id.to_def_id()).self_ty();
|
||||
if !contains_ty(ret_ty, self_ty);
|
||||
|
||||
then {
|
||||
|
@ -164,8 +164,7 @@ impl<'tcx> LateLintPass<'tcx> for MissingDoc {
|
||||
}
|
||||
|
||||
fn check_trait_item(&mut self, cx: &LateContext<'tcx>, trait_item: &'tcx hir::TraitItem<'_>) {
|
||||
let def_id = cx.tcx.hir().local_def_id(trait_item.hir_id);
|
||||
let (article, desc) = cx.tcx.article_and_description(def_id.to_def_id());
|
||||
let (article, desc) = cx.tcx.article_and_description(trait_item.def_id.to_def_id());
|
||||
|
||||
self.check_missing_docs_attrs(cx, &trait_item.attrs, trait_item.span, article, desc);
|
||||
}
|
||||
|
@ -71,7 +71,7 @@ impl<'tcx> LateLintPass<'tcx> for MutableKeyType {
|
||||
|
||||
fn check_trait_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx hir::TraitItem<'tcx>) {
|
||||
if let hir::TraitItemKind::Fn(ref sig, ..) = item.kind {
|
||||
check_sig(cx, item.hir_id, &sig.decl);
|
||||
check_sig(cx, item.hir_id(), &sig.decl);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -206,7 +206,7 @@ impl<'tcx> LateLintPass<'tcx> for PassByRefOrValue {
|
||||
}
|
||||
|
||||
if let hir::TraitItemKind::Fn(method_sig, _) = &item.kind {
|
||||
self.check_poly_fn(cx, item.hir_id, &*method_sig.decl, None);
|
||||
self.check_poly_fn(cx, item.hir_id(), &*method_sig.decl, None);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -147,7 +147,7 @@ impl<'tcx> LateLintPass<'tcx> for Ptr {
|
||||
} else {
|
||||
None
|
||||
};
|
||||
check_fn(cx, &sig.decl, item.hir_id, body_id);
|
||||
check_fn(cx, &sig.decl, item.hir_id(), body_id);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user