Skip to content

Commit 7e1914f

Browse files
committed
hir: replace NodeId with HirId in trait_impls
1 parent 913ad6d commit 7e1914f

File tree

7 files changed

+15
-14
lines changed

7 files changed

+15
-14
lines changed

src/librustc/hir/lowering.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ pub struct LoweringContext<'a> {
8989
bodies: BTreeMap<hir::BodyId, hir::Body>,
9090
exported_macros: Vec<hir::MacroDef>,
9191

92-
trait_impls: BTreeMap<DefId, Vec<NodeId>>,
92+
trait_impls: BTreeMap<DefId, Vec<hir::HirId>>,
9393
trait_auto_impl: BTreeMap<DefId, NodeId>,
9494

9595
modules: BTreeMap<NodeId, hir::ModuleItems>,
@@ -2967,6 +2967,7 @@ impl<'a> LoweringContext<'a> {
29672967
// method, it will not be considered an in-band
29682968
// lifetime to be added, but rather a reference to a
29692969
// parent lifetime.
2970+
let lowered_trait_impl_id = self.lower_node_id(id).hir_id;
29702971
let (generics, (trait_ref, lowered_ty)) = self.add_in_band_defs(
29712972
ast_generics,
29722973
def_id,
@@ -2978,7 +2979,8 @@ impl<'a> LoweringContext<'a> {
29782979

29792980
if let Some(ref trait_ref) = trait_ref {
29802981
if let Def::Trait(def_id) = trait_ref.path.def {
2981-
this.trait_impls.entry(def_id).or_default().push(id);
2982+
this.trait_impls.entry(def_id).or_default().push(
2983+
lowered_trait_impl_id);
29822984
}
29832985
}
29842986

src/librustc/hir/map/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -555,7 +555,7 @@ impl<'hir> Map<'hir> {
555555
}
556556
}
557557

558-
pub fn trait_impls(&self, trait_did: DefId) -> &'hir [NodeId] {
558+
pub fn trait_impls(&self, trait_did: DefId) -> &'hir [HirId] {
559559
self.dep_graph.read(DepNode::new_no_params(DepKind::AllLocalTraitImpls));
560560

561561
// N.B., intentionally bypass `self.forest.krate()` so that we

src/librustc/hir/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -723,7 +723,7 @@ pub struct Crate {
723723
pub trait_items: BTreeMap<TraitItemId, TraitItem>,
724724
pub impl_items: BTreeMap<ImplItemId, ImplItem>,
725725
pub bodies: BTreeMap<BodyId, Body>,
726-
pub trait_impls: BTreeMap<DefId, Vec<NodeId>>,
726+
pub trait_impls: BTreeMap<DefId, Vec<HirId>>,
727727
pub trait_auto_impl: BTreeMap<DefId, NodeId>,
728728

729729
/// A list of the body ids written out in the order in which they

src/librustc/ty/trait_def.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -179,8 +179,8 @@ pub(super) fn trait_impls_of_provider<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
179179
}
180180
}
181181

182-
for &node_id in tcx.hir().trait_impls(trait_id) {
183-
add_impl(tcx.hir().local_def_id(node_id));
182+
for &hir_id in tcx.hir().trait_impls(trait_id) {
183+
add_impl(tcx.hir().local_def_id_from_hir_id(hir_id));
184184
}
185185
}
186186

src/librustc_typeck/coherence/builtin.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ impl<'a, 'tcx> Checker<'a, 'tcx> {
3737
{
3838
if Some(self.trait_def_id) == trait_def_id {
3939
for &impl_id in self.tcx.hir().trait_impls(self.trait_def_id) {
40-
let impl_def_id = self.tcx.hir().local_def_id(impl_id);
40+
let impl_def_id = self.tcx.hir().local_def_id_from_hir_id(impl_id);
4141
f(self.tcx, impl_def_id);
4242
}
4343
}

src/librustc_typeck/coherence/mod.rs

+5-6
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,21 @@
55
// done by the orphan and overlap modules. Then we build up various
66
// mappings. That mapping code resides here.
77

8+
use crate::hir::HirId;
89
use crate::hir::def_id::{DefId, LOCAL_CRATE};
910
use rustc::traits;
1011
use rustc::ty::{self, TyCtxt, TypeFoldable};
1112
use rustc::ty::query::Providers;
1213
use rustc::util::common::time;
1314

14-
use syntax::ast;
15-
1615
mod builtin;
1716
mod inherent_impls;
1817
mod inherent_impls_overlap;
1918
mod orphan;
2019
mod unsafety;
2120

22-
fn check_impl<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, node_id: ast::NodeId) {
23-
let impl_def_id = tcx.hir().local_def_id(node_id);
21+
fn check_impl<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, hir_id: HirId) {
22+
let impl_def_id = tcx.hir().local_def_id_from_hir_id(hir_id);
2423

2524
// If there are no traits, then this implementation must have a
2625
// base type.
@@ -160,8 +159,8 @@ pub fn check_coherence<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) {
160159
/// Overlap: no two impls for the same trait are implemented for the
161160
/// same type. Likewise, no two inherent impls for a given type
162161
/// constructor provide a method with the same name.
163-
fn check_impl_overlap<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, node_id: ast::NodeId) {
164-
let impl_def_id = tcx.hir().local_def_id(node_id);
162+
fn check_impl_overlap<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, hir_id: HirId) {
163+
let impl_def_id = tcx.hir().local_def_id_from_hir_id(hir_id);
165164
let trait_ref = tcx.impl_trait_ref(impl_def_id).unwrap();
166165
let trait_def_id = trait_ref.def_id;
167166

src/librustdoc/passes/collect_trait_impls.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ pub fn collect_trait_impls(krate: Crate, cx: &DocContext<'_>) -> Crate {
119119
// doesn't work with it anyway, so pull them from the HIR map instead
120120
for &trait_did in cx.all_traits.iter() {
121121
for &impl_node in cx.tcx.hir().trait_impls(trait_did) {
122-
let impl_did = cx.tcx.hir().local_def_id(impl_node);
122+
let impl_did = cx.tcx.hir().local_def_id_from_hir_id(impl_node);
123123
inline::build_impl(cx, impl_did, &mut new_items);
124124
}
125125
}

0 commit comments

Comments
 (0)