Skip to content

Commit 4543fc2

Browse files
committed
hir: remove NodeId from AnonConst
1 parent d959f44 commit 4543fc2

File tree

9 files changed

+21
-23
lines changed

9 files changed

+21
-23
lines changed

src/librustc/hir/lowering.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3811,9 +3811,8 @@ impl<'a> LoweringContext<'a> {
38113811

38123812
fn lower_anon_const(&mut self, c: &AnonConst) -> hir::AnonConst {
38133813
self.with_new_scopes(|this| {
3814-
let LoweredNodeId { node_id, hir_id } = this.lower_node_id(c.id);
3814+
let LoweredNodeId { node_id: _, hir_id } = this.lower_node_id(c.id);
38153815
hir::AnonConst {
3816-
id: node_id,
38173816
hir_id,
38183817
body: this.lower_body(None, |this| this.lower_expr(&c.value)),
38193818
}

src/librustc/hir/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1322,7 +1322,6 @@ impl BodyOwnerKind {
13221322
/// explicit discriminant values for enum variants.
13231323
#[derive(Copy, Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Debug)]
13241324
pub struct AnonConst {
1325-
pub id: NodeId,
13261325
pub hir_id: HirId,
13271326
pub body: BodyId,
13281327
}

src/librustc/ich/impls_hir.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -546,7 +546,6 @@ impl_stable_hash_for!(enum hir::UnsafeSource {
546546
});
547547

548548
impl_stable_hash_for!(struct hir::AnonConst {
549-
id,
550549
hir_id,
551550
body
552551
});

src/librustc_metadata/encoder.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1667,7 +1667,7 @@ impl<'a, 'b, 'tcx> Visitor<'tcx> for EncodeVisitor<'a, 'b, 'tcx> {
16671667
intravisit::walk_variant(self, v, g, id);
16681668

16691669
if let Some(ref discr) = v.node.disr_expr {
1670-
let def_id = self.index.tcx.hir().local_def_id(discr.id);
1670+
let def_id = self.index.tcx.hir().local_def_id_from_hir_id(discr.hir_id);
16711671
self.index.record(def_id, IsolatedEncoder::encode_info_for_anon_const, def_id);
16721672
}
16731673
}
@@ -1719,7 +1719,7 @@ impl<'a, 'b, 'tcx> IndexBuilder<'a, 'b, 'tcx> {
17191719
fn encode_info_for_ty(&mut self, ty: &hir::Ty) {
17201720
match ty.node {
17211721
hir::TyKind::Array(_, ref length) => {
1722-
let def_id = self.tcx.hir().local_def_id(length.id);
1722+
let def_id = self.tcx.hir().local_def_id_from_hir_id(length.hir_id);
17231723
self.record(def_id, IsolatedEncoder::encode_info_for_anon_const, def_id);
17241724
}
17251725
_ => {}

src/librustc_mir/hair/cx/expr.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -560,7 +560,7 @@ fn make_mirror_unadjusted<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>,
560560

561561
// Now comes the rote stuff:
562562
hir::ExprKind::Repeat(ref v, ref count) => {
563-
let def_id = cx.tcx.hir().local_def_id(count.id);
563+
let def_id = cx.tcx.hir().local_def_id_from_hir_id(count.hir_id);
564564
let substs = InternalSubsts::identity_for_item(cx.tcx.global_tcx(), def_id);
565565
let instance = ty::Instance::resolve(
566566
cx.tcx.global_tcx(),

src/librustc_typeck/astconv.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1798,7 +1798,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx> + 'o {
17981798
self.associated_path_to_ty(ast_ty.hir_id, ast_ty.span, ty, def, segment, false).0
17991799
}
18001800
hir::TyKind::Array(ref ty, ref length) => {
1801-
let length_def_id = tcx.hir().local_def_id(length.id);
1801+
let length_def_id = tcx.hir().local_def_id_from_hir_id(length.hir_id);
18021802
let substs = InternalSubsts::identity_for_item(tcx, length_def_id);
18031803
let length = ty::LazyConst::Unevaluated(length_def_id, substs);
18041804
let length = tcx.mk_lazy_const(length);

src/librustc_typeck/check/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1870,7 +1870,7 @@ pub fn check_enum<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
18701870

18711871
for v in vs {
18721872
if let Some(ref e) = v.node.disr_expr {
1873-
tcx.typeck_tables_of(tcx.hir().local_def_id(e.id));
1873+
tcx.typeck_tables_of(tcx.hir().local_def_id_from_hir_id(e.hir_id));
18741874
}
18751875
}
18761876

@@ -4552,7 +4552,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
45524552
tcx.mk_array(element_ty, args.len() as u64)
45534553
}
45544554
ExprKind::Repeat(ref element, ref count) => {
4555-
let count_def_id = tcx.hir().local_def_id(count.id);
4555+
let count_def_id = tcx.hir().local_def_id_from_hir_id(count.hir_id);
45564556
let param_env = ty::ParamEnv::empty();
45574557
let substs = InternalSubsts::identity_for_item(tcx.global_tcx(), count_def_id);
45584558
let instance = ty::Instance::resolve(

src/librustc_typeck/collect.rs

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -532,7 +532,7 @@ fn convert_enum_variant_types<'a, 'tcx>(
532532
let wrapped_discr = prev_discr.map_or(initial, |d| d.wrap_incr(tcx));
533533
prev_discr = Some(
534534
if let Some(ref e) = variant.node.disr_expr {
535-
let expr_did = tcx.hir().local_def_id(e.id);
535+
let expr_did = tcx.hir().local_def_id_from_hir_id(e.hir_id);
536536
def.eval_explicit_discr(tcx, expr_did)
537537
} else if let Some(discr) = repr_type.disr_incr(tcx, prev_discr) {
538538
Some(discr)
@@ -637,7 +637,7 @@ fn adt_def<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> &'tcx ty::Ad
637637
let did = tcx.hir().local_def_id(v.node.data.id());
638638
let discr = if let Some(ref e) = v.node.disr_expr {
639639
distance_from_explicit = 0;
640-
ty::VariantDiscr::Explicit(tcx.hir().local_def_id(e.id))
640+
ty::VariantDiscr::Explicit(tcx.hir().local_def_id_from_hir_id(e.hir_id))
641641
} else {
642642
ty::VariantDiscr::Relative(distance_from_explicit)
643643
};
@@ -1142,11 +1142,11 @@ fn report_assoc_ty_on_inherent_impl<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, span:
11421142
fn type_of<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> Ty<'tcx> {
11431143
use rustc::hir::*;
11441144

1145-
let node_id = tcx.hir().as_local_node_id(def_id).unwrap();
1145+
let hir_id = tcx.hir().as_local_hir_id(def_id).unwrap();
11461146

11471147
let icx = ItemCtxt::new(tcx, def_id);
11481148

1149-
match tcx.hir().get(node_id) {
1149+
match tcx.hir().get_by_hir_id(hir_id) {
11501150
Node::TraitItem(item) => match item.node {
11511151
TraitItemKind::Method(..) => {
11521152
let substs = InternalSubsts::identity_for_item(tcx, def_id);
@@ -1166,7 +1166,7 @@ fn type_of<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> Ty<'tcx> {
11661166
ImplItemKind::Const(ref ty, _) => icx.to_ty(ty),
11671167
ImplItemKind::Existential(_) => {
11681168
if tcx
1169-
.impl_trait_ref(tcx.hir().get_parent_did(node_id))
1169+
.impl_trait_ref(tcx.hir().get_parent_did_by_hir_id(hir_id))
11701170
.is_none()
11711171
{
11721172
report_assoc_ty_on_inherent_impl(tcx, item.span);
@@ -1176,7 +1176,7 @@ fn type_of<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> Ty<'tcx> {
11761176
}
11771177
ImplItemKind::Type(ref ty) => {
11781178
if tcx
1179-
.impl_trait_ref(tcx.hir().get_parent_did(node_id))
1179+
.impl_trait_ref(tcx.hir().get_parent_did_by_hir_id(hir_id))
11801180
.is_none()
11811181
{
11821182
report_assoc_ty_on_inherent_impl(tcx, item.span);
@@ -1259,7 +1259,7 @@ fn type_of<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> Ty<'tcx> {
12591259
..
12601260
}) => match *def {
12611261
VariantData::Unit(..) | VariantData::Struct(..) => {
1262-
tcx.type_of(tcx.hir().get_parent_did(node_id))
1262+
tcx.type_of(tcx.hir().get_parent_did_by_hir_id(hir_id))
12631263
}
12641264
VariantData::Tuple(..) => {
12651265
let substs = InternalSubsts::identity_for_item(tcx, def_id);
@@ -1274,7 +1274,6 @@ fn type_of<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> Ty<'tcx> {
12741274
..
12751275
}) => {
12761276
if gen.is_some() {
1277-
let hir_id = tcx.hir().node_to_hir_id(node_id);
12781277
return tcx.typeck_tables_of(def_id).node_type(hir_id);
12791278
}
12801279

@@ -1285,7 +1284,9 @@ fn type_of<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> Ty<'tcx> {
12851284
tcx.mk_closure(def_id, substs)
12861285
}
12871286

1288-
Node::AnonConst(_) => match tcx.hir().get(tcx.hir().get_parent_node(node_id)) {
1287+
Node::AnonConst(_) => match tcx.hir().get_by_hir_id(
1288+
tcx.hir().get_parent_node_by_hir_id(hir_id))
1289+
{
12891290
Node::Ty(&hir::Ty {
12901291
node: hir::TyKind::Array(_, ref constant),
12911292
..
@@ -1297,7 +1298,7 @@ fn type_of<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> Ty<'tcx> {
12971298
| Node::Expr(&hir::Expr {
12981299
node: ExprKind::Repeat(_, ref constant),
12991300
..
1300-
}) if constant.id == node_id =>
1301+
}) if constant.hir_id == hir_id =>
13011302
{
13021303
tcx.types.usize
13031304
}
@@ -1309,9 +1310,9 @@ fn type_of<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> Ty<'tcx> {
13091310
..
13101311
},
13111312
..
1312-
}) if e.id == node_id =>
1313+
}) if e.hir_id == hir_id =>
13131314
{
1314-
tcx.adt_def(tcx.hir().get_parent_did(node_id))
1315+
tcx.adt_def(tcx.hir().get_parent_did_by_hir_id(hir_id))
13151316
.repr
13161317
.discr_type()
13171318
.to_ty(tcx)

src/librustdoc/clean/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2531,7 +2531,7 @@ impl Clean<Type> for hir::Ty {
25312531
}
25322532
TyKind::Slice(ref ty) => Slice(box ty.clean(cx)),
25332533
TyKind::Array(ref ty, ref length) => {
2534-
let def_id = cx.tcx.hir().local_def_id(length.id);
2534+
let def_id = cx.tcx.hir().local_def_id_from_hir_id(length.hir_id);
25352535
let param_env = cx.tcx.param_env(def_id);
25362536
let substs = InternalSubsts::identity_for_item(cx.tcx, def_id);
25372537
let cid = GlobalId {

0 commit comments

Comments
 (0)