Skip to content

Commit a189cb2

Browse files
committed
Remove redundant def_id lookups
1 parent bd2f1cb commit a189cb2

File tree

2 files changed

+2
-4
lines changed

2 files changed

+2
-4
lines changed

compiler/rustc_middle/src/ty/consts.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,7 @@ impl<'tcx> Const<'tcx> {
9292
let item_id = tcx.hir().get_parent_node(hir_id);
9393
let item_def_id = tcx.hir().local_def_id(item_id);
9494
let generics = tcx.generics_of(item_def_id.to_def_id());
95-
let index =
96-
generics.param_def_id_to_index[&tcx.hir().local_def_id(hir_id).to_def_id()];
95+
let index = generics.param_def_id_to_index[&def_id];
9796
let name = tcx.hir().name(hir_id);
9897
ty::ConstKind::Param(ty::ParamConst::new(index, name))
9998
}

compiler/rustc_mir_build/src/thir/cx/expr.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -813,8 +813,7 @@ fn convert_path_expr<'a, 'tcx>(
813813
let item_id = cx.tcx.hir().get_parent_node(hir_id);
814814
let item_def_id = cx.tcx.hir().local_def_id(item_id);
815815
let generics = cx.tcx.generics_of(item_def_id);
816-
let local_def_id = cx.tcx.hir().local_def_id(hir_id);
817-
let index = generics.param_def_id_to_index[&local_def_id.to_def_id()];
816+
let index = generics.param_def_id_to_index[&def_id];
818817
let name = cx.tcx.hir().name(hir_id);
819818
let val = ty::ConstKind::Param(ty::ParamConst::new(index, name));
820819
ExprKind::Literal {

0 commit comments

Comments
 (0)