hir: remove NodeId from ImplItem
This commit is contained in:
parent
c2e517e0c4
commit
a29ceb9f51
15 changed files with 30 additions and 27 deletions
|
@ -878,7 +878,6 @@ pub fn walk_trait_item_ref<'v, V: Visitor<'v>>(visitor: &mut V, trait_item_ref:
|
|||
pub fn walk_impl_item<'v, V: Visitor<'v>>(visitor: &mut V, impl_item: &'v ImplItem) {
|
||||
// N.B., deliberately force a compilation error if/when new fields are added.
|
||||
let ImplItem {
|
||||
id: _,
|
||||
hir_id: _,
|
||||
ident,
|
||||
ref vis,
|
||||
|
|
|
@ -3426,7 +3426,6 @@ impl<'a> LoweringContext<'a> {
|
|||
};
|
||||
|
||||
hir::ImplItem {
|
||||
id: node_id,
|
||||
hir_id,
|
||||
ident: i.ident,
|
||||
attrs: self.lower_attrs(&i.attrs),
|
||||
|
|
|
@ -398,7 +398,7 @@ impl<'a, 'hir> Visitor<'hir> for NodeCollector<'a, 'hir> {
|
|||
|
||||
fn visit_impl_item(&mut self, ii: &'hir ImplItem) {
|
||||
debug_assert_eq!(ii.hir_id.owner,
|
||||
self.definitions.opt_def_index(ii.id).unwrap());
|
||||
self.definitions.opt_def_index(self.hir_to_node_id[&ii.hir_id]).unwrap());
|
||||
self.with_dep_node_owner(ii.hir_id.owner, ii, |this| {
|
||||
this.insert(ii.span, ii.hir_id, Node::ImplItem(ii));
|
||||
|
||||
|
|
|
@ -357,7 +357,7 @@ impl<'hir> Map<'hir> {
|
|||
}
|
||||
}
|
||||
Node::ImplItem(item) => {
|
||||
let def_id = self.local_def_id(item.id);
|
||||
let def_id = self.local_def_id_from_hir_id(item.hir_id);
|
||||
match item.node {
|
||||
ImplItemKind::Const(..) => Some(Def::AssociatedConst(def_id)),
|
||||
ImplItemKind::Method(..) => Some(Def::Method(def_id)),
|
||||
|
|
|
@ -1710,7 +1710,6 @@ pub struct ImplItemId {
|
|||
/// Represents anything within an `impl` block
|
||||
#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
|
||||
pub struct ImplItem {
|
||||
pub id: NodeId,
|
||||
pub ident: Ident,
|
||||
pub hir_id: HirId,
|
||||
pub vis: Visibility,
|
||||
|
|
|
@ -703,7 +703,6 @@ impl<'a> HashStable<StableHashingContext<'a>> for hir::ImplItem {
|
|||
hcx: &mut StableHashingContext<'a>,
|
||||
hasher: &mut StableHasher<W>) {
|
||||
let hir::ImplItem {
|
||||
id: _,
|
||||
hir_id: _,
|
||||
ident,
|
||||
ref vis,
|
||||
|
|
|
@ -48,7 +48,7 @@ fn method_might_be_inlined<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
|||
impl_item: &hir::ImplItem,
|
||||
impl_src: DefId) -> bool {
|
||||
let codegen_fn_attrs = tcx.codegen_fn_attrs(impl_item.hir_id.owner_def_id());
|
||||
let generics = tcx.generics_of(tcx.hir().local_def_id(impl_item.id));
|
||||
let generics = tcx.generics_of(tcx.hir().local_def_id_from_hir_id(impl_item.hir_id));
|
||||
if codegen_fn_attrs.requests_inline() || generics.requires_monomorphization(tcx) {
|
||||
return true
|
||||
}
|
||||
|
|
|
@ -355,7 +355,8 @@ impl<'a, 'tcx> Visitor<'tcx> for MissingStabilityAnnotations<'a, 'tcx> {
|
|||
}
|
||||
|
||||
fn visit_impl_item(&mut self, ii: &'tcx hir::ImplItem) {
|
||||
let impl_def_id = self.tcx.hir().local_def_id(self.tcx.hir().get_parent(ii.id));
|
||||
let impl_def_id = self.tcx.hir().local_def_id_from_hir_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.hir_id, ii.span, "item");
|
||||
}
|
||||
|
|
|
@ -1112,11 +1112,12 @@ impl LintPass for UnreachablePub {
|
|||
}
|
||||
|
||||
impl UnreachablePub {
|
||||
fn perform_lint(&self, cx: &LateContext<'_, '_>, what: &str, id: ast::NodeId,
|
||||
fn perform_lint(&self, cx: &LateContext<'_, '_>, what: &str, id: hir::HirId,
|
||||
vis: &hir::Visibility, span: Span, exportable: bool) {
|
||||
let mut applicability = Applicability::MachineApplicable;
|
||||
let node_id = cx.tcx.hir().hir_to_node_id(id);
|
||||
match vis.node {
|
||||
hir::VisibilityKind::Public if !cx.access_levels.is_reachable(id) => {
|
||||
hir::VisibilityKind::Public if !cx.access_levels.is_reachable(node_id) => {
|
||||
if span.ctxt().outer().expn_info().is_some() {
|
||||
applicability = Applicability::MaybeIncorrect;
|
||||
}
|
||||
|
@ -1148,20 +1149,20 @@ impl UnreachablePub {
|
|||
|
||||
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnreachablePub {
|
||||
fn check_item(&mut self, cx: &LateContext<'_, '_>, item: &hir::Item) {
|
||||
self.perform_lint(cx, "item", item.id, &item.vis, item.span, true);
|
||||
self.perform_lint(cx, "item", item.hir_id, &item.vis, item.span, true);
|
||||
}
|
||||
|
||||
fn check_foreign_item(&mut self, cx: &LateContext<'_, '_>, foreign_item: &hir::ForeignItem) {
|
||||
self.perform_lint(cx, "item", foreign_item.id, &foreign_item.vis,
|
||||
self.perform_lint(cx, "item", foreign_item.hir_id, &foreign_item.vis,
|
||||
foreign_item.span, true);
|
||||
}
|
||||
|
||||
fn check_struct_field(&mut self, cx: &LateContext<'_, '_>, field: &hir::StructField) {
|
||||
self.perform_lint(cx, "field", field.id, &field.vis, field.span, false);
|
||||
self.perform_lint(cx, "field", field.hir_id, &field.vis, field.span, false);
|
||||
}
|
||||
|
||||
fn check_impl_item(&mut self, cx: &LateContext<'_, '_>, impl_item: &hir::ImplItem) {
|
||||
self.perform_lint(cx, "item", impl_item.id, &impl_item.vis, impl_item.span, false);
|
||||
self.perform_lint(cx, "item", impl_item.hir_id, &impl_item.vis, impl_item.span, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1006,7 +1006,7 @@ impl<'b, 'a, 'v> ItemLikeVisitor<'v> for RootCollector<'b, 'a, 'v> {
|
|||
fn visit_impl_item(&mut self, ii: &'v hir::ImplItem) {
|
||||
match ii.node {
|
||||
hir::ImplItemKind::Method(hir::MethodSig { .. }, _) => {
|
||||
let def_id = self.tcx.hir().local_def_id(ii.id);
|
||||
let def_id = self.tcx.hir().local_def_id_from_hir_id(ii.hir_id);
|
||||
self.push_if_root(def_id);
|
||||
}
|
||||
_ => { /* Nothing to do here */ }
|
||||
|
|
|
@ -1318,7 +1318,9 @@ impl<'a, 'tcx> Visitor<'tcx> for ObsoleteVisiblePrivateTypesVisitor<'a, 'tcx> {
|
|||
match impl_item.node {
|
||||
hir::ImplItemKind::Const(..) |
|
||||
hir::ImplItemKind::Method(..) => {
|
||||
self.access_levels.is_reachable(impl_item.id)
|
||||
let node_id = self.tcx.hir().hir_to_node_id(
|
||||
impl_item.hir_id);
|
||||
self.access_levels.is_reachable(node_id)
|
||||
}
|
||||
hir::ImplItemKind::Existential(..) |
|
||||
hir::ImplItemKind::Type(_) => false,
|
||||
|
@ -1340,10 +1342,11 @@ impl<'a, 'tcx> Visitor<'tcx> for ObsoleteVisiblePrivateTypesVisitor<'a, 'tcx> {
|
|||
// don't erroneously report errors for private
|
||||
// types in private items.
|
||||
let impl_item = self.tcx.hir().impl_item(impl_item_ref.id);
|
||||
let node_id = self.tcx.hir().hir_to_node_id(impl_item.hir_id);
|
||||
match impl_item.node {
|
||||
hir::ImplItemKind::Const(..) |
|
||||
hir::ImplItemKind::Method(..)
|
||||
if self.item_is_public(&impl_item.id, &impl_item.vis) =>
|
||||
if self.item_is_public(&node_id, &impl_item.vis) =>
|
||||
{
|
||||
intravisit::walk_impl_item(self, impl_item)
|
||||
}
|
||||
|
|
|
@ -1554,7 +1554,8 @@ fn check_impl_items_against_trait<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
|||
// Check existing impl methods to see if they are both present in trait
|
||||
// and compatible with trait signature
|
||||
for impl_item in impl_items() {
|
||||
let ty_impl_item = tcx.associated_item(tcx.hir().local_def_id(impl_item.id));
|
||||
let ty_impl_item = tcx.associated_item(
|
||||
tcx.hir().local_def_id_from_hir_id(impl_item.hir_id));
|
||||
let ty_trait_item = tcx.associated_items(impl_trait_ref.def_id)
|
||||
.find(|ac| Namespace::from(&impl_item.node) == Namespace::from(ac.kind) &&
|
||||
tcx.hygienic_eq(ty_impl_item.ident, ac.ident, impl_trait_ref.def_id))
|
||||
|
|
|
@ -1030,7 +1030,7 @@ impl<'a, 'tcx> ItemLikeVisitor<'tcx> for CheckTypeWellFormedVisitor<'a, 'tcx> {
|
|||
|
||||
fn visit_impl_item(&mut self, impl_item: &'tcx hir::ImplItem) {
|
||||
debug!("visit_impl_item: {:?}", impl_item);
|
||||
let def_id = self.tcx.hir().local_def_id(impl_item.id);
|
||||
let def_id = self.tcx.hir().local_def_id_from_hir_id(impl_item.hir_id);
|
||||
self.tcx.ensure().check_impl_item_well_formed(def_id);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -157,7 +157,7 @@ impl<'a, 'tcx> Visitor<'tcx> for CollectItemTypesVisitor<'a, 'tcx> {
|
|||
}
|
||||
|
||||
fn visit_impl_item(&mut self, impl_item: &'tcx hir::ImplItem) {
|
||||
convert_impl_item(self.tcx, impl_item.id);
|
||||
convert_impl_item(self.tcx, impl_item.hir_id);
|
||||
intravisit::walk_impl_item(self, impl_item);
|
||||
}
|
||||
}
|
||||
|
@ -500,12 +500,12 @@ fn convert_trait_item<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, trait_item_id: hir:
|
|||
tcx.predicates_of(def_id);
|
||||
}
|
||||
|
||||
fn convert_impl_item<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, impl_item_id: ast::NodeId) {
|
||||
let def_id = tcx.hir().local_def_id(impl_item_id);
|
||||
fn convert_impl_item<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, impl_item_id: hir::HirId) {
|
||||
let def_id = tcx.hir().local_def_id_from_hir_id(impl_item_id);
|
||||
tcx.generics_of(def_id);
|
||||
tcx.type_of(def_id);
|
||||
tcx.predicates_of(def_id);
|
||||
if let hir::ImplItemKind::Method(..) = tcx.hir().expect_impl_item(impl_item_id).node {
|
||||
if let hir::ImplItemKind::Method(..) = tcx.hir().expect_impl_item_by_hir_id(impl_item_id).node {
|
||||
tcx.fn_sig(def_id);
|
||||
}
|
||||
}
|
||||
|
@ -1485,7 +1485,7 @@ fn find_existential_constraints<'a, 'tcx>(
|
|||
}
|
||||
}
|
||||
fn visit_impl_item(&mut self, it: &'tcx ImplItem) {
|
||||
let def_id = self.tcx.hir().local_def_id(it.id);
|
||||
let def_id = self.tcx.hir().local_def_id_from_hir_id(it.hir_id);
|
||||
// the existential type itself or its children are not within its reveal scope
|
||||
if def_id != self.def_id {
|
||||
self.check(def_id);
|
||||
|
|
|
@ -2055,14 +2055,15 @@ impl Clean<Item> for hir::ImplItem {
|
|||
generics: Generics::default(),
|
||||
}, true),
|
||||
};
|
||||
let local_did = cx.tcx.hir().local_def_id_from_hir_id(self.hir_id);
|
||||
Item {
|
||||
name: Some(self.ident.name.clean(cx)),
|
||||
source: self.span.clean(cx),
|
||||
attrs: self.attrs.clean(cx),
|
||||
def_id: cx.tcx.hir().local_def_id(self.id),
|
||||
def_id: local_did,
|
||||
visibility: self.vis.clean(cx),
|
||||
stability: get_stability(cx, cx.tcx.hir().local_def_id(self.id)),
|
||||
deprecation: get_deprecation(cx, cx.tcx.hir().local_def_id(self.id)),
|
||||
stability: get_stability(cx, local_did),
|
||||
deprecation: get_deprecation(cx, local_did),
|
||||
inner,
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue