Skip to content

Commit

Permalink
Rollup merge of #80232 - bugadani:roundtrip, r=estebank
Browse files Browse the repository at this point in the history
Remove redundant def_id lookups

Simplify `DefId -> LocalDefId -> HirId -> LocalDefId -> DefId` chains.
  • Loading branch information
Dylan-DPC authored Jan 13, 2021
2 parents 11bca6b + a189cb2 commit ac7267a
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 4 deletions.
3 changes: 1 addition & 2 deletions compiler/rustc_middle/src/ty/consts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,7 @@ impl<'tcx> Const<'tcx> {
let item_id = tcx.hir().get_parent_node(hir_id);
let item_def_id = tcx.hir().local_def_id(item_id);
let generics = tcx.generics_of(item_def_id.to_def_id());
let index =
generics.param_def_id_to_index[&tcx.hir().local_def_id(hir_id).to_def_id()];
let index = generics.param_def_id_to_index[&def_id];
let name = tcx.hir().name(hir_id);
ty::ConstKind::Param(ty::ParamConst::new(index, name))
}
Expand Down
3 changes: 1 addition & 2 deletions compiler/rustc_mir_build/src/thir/cx/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -813,8 +813,7 @@ fn convert_path_expr<'a, 'tcx>(
let item_id = cx.tcx.hir().get_parent_node(hir_id);
let item_def_id = cx.tcx.hir().local_def_id(item_id);
let generics = cx.tcx.generics_of(item_def_id);
let local_def_id = cx.tcx.hir().local_def_id(hir_id);
let index = generics.param_def_id_to_index[&local_def_id.to_def_id()];
let index = generics.param_def_id_to_index[&def_id];
let name = cx.tcx.hir().name(hir_id);
let val = ty::ConstKind::Param(ty::ParamConst::new(index, name));
ExprKind::Literal {
Expand Down

0 comments on commit ac7267a

Please sign in to comment.