Skip to content

Commit cb1de29

Browse files
committed
Use parent's identity_args to instantiate the type of const param
1 parent d572e6d commit cb1de29

1 file changed

Lines changed: 12 additions & 9 deletions

File tree

compiler/rustc_hir_analysis/src/collect.rs

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1479,24 +1479,27 @@ fn rendered_precise_capturing_args<'tcx>(
14791479

14801480
fn const_param_default<'tcx>(
14811481
tcx: TyCtxt<'tcx>,
1482-
def_id: LocalDefId,
1482+
local_def_id: LocalDefId,
14831483
) -> ty::EarlyBinder<'tcx, Const<'tcx>> {
14841484
let hir::Node::GenericParam(hir::GenericParam {
14851485
kind: hir::GenericParamKind::Const { default: Some(default_ct), .. },
14861486
..
1487-
}) = tcx.hir_node_by_def_id(def_id)
1487+
}) = tcx.hir_node_by_def_id(local_def_id)
14881488
else {
14891489
span_bug!(
1490-
tcx.def_span(def_id),
1490+
tcx.def_span(local_def_id),
14911491
"`const_param_default` expected a generic parameter with a constant"
14921492
)
14931493
};
1494-
let icx = ItemCtxt::new(tcx, def_id);
1495-
let identity_args = ty::GenericArgs::identity_for_item(tcx, def_id);
1496-
let ct = icx.lowerer().lower_const_arg(
1497-
default_ct,
1498-
FeedConstTy::with_type_of(tcx, def_id.to_def_id(), identity_args),
1499-
);
1494+
1495+
let icx = ItemCtxt::new(tcx, local_def_id);
1496+
1497+
let def_id = local_def_id.to_def_id();
1498+
let identity_args = ty::GenericArgs::identity_for_item(tcx, tcx.parent(def_id));
1499+
1500+
let ct = icx
1501+
.lowerer()
1502+
.lower_const_arg(default_ct, FeedConstTy::with_type_of(tcx, def_id, identity_args));
15001503
ty::EarlyBinder::bind(ct)
15011504
}
15021505

0 commit comments

Comments
 (0)