Use parent's identity_args to instantiate the type of const param
This commit is contained in:
parent
d572e6d415
commit
cb1de29659
1 changed files with 12 additions and 9 deletions
|
|
@ -1479,24 +1479,27 @@ fn rendered_precise_capturing_args<'tcx>(
|
|||
|
||||
fn const_param_default<'tcx>(
|
||||
tcx: TyCtxt<'tcx>,
|
||||
def_id: LocalDefId,
|
||||
local_def_id: LocalDefId,
|
||||
) -> ty::EarlyBinder<'tcx, Const<'tcx>> {
|
||||
let hir::Node::GenericParam(hir::GenericParam {
|
||||
kind: hir::GenericParamKind::Const { default: Some(default_ct), .. },
|
||||
..
|
||||
}) = tcx.hir_node_by_def_id(def_id)
|
||||
}) = tcx.hir_node_by_def_id(local_def_id)
|
||||
else {
|
||||
span_bug!(
|
||||
tcx.def_span(def_id),
|
||||
tcx.def_span(local_def_id),
|
||||
"`const_param_default` expected a generic parameter with a constant"
|
||||
)
|
||||
};
|
||||
let icx = ItemCtxt::new(tcx, def_id);
|
||||
let identity_args = ty::GenericArgs::identity_for_item(tcx, def_id);
|
||||
let ct = icx.lowerer().lower_const_arg(
|
||||
default_ct,
|
||||
FeedConstTy::with_type_of(tcx, def_id.to_def_id(), identity_args),
|
||||
);
|
||||
|
||||
let icx = ItemCtxt::new(tcx, local_def_id);
|
||||
|
||||
let def_id = local_def_id.to_def_id();
|
||||
let identity_args = ty::GenericArgs::identity_for_item(tcx, tcx.parent(def_id));
|
||||
|
||||
let ct = icx
|
||||
.lowerer()
|
||||
.lower_const_arg(default_ct, FeedConstTy::with_type_of(tcx, def_id, identity_args));
|
||||
ty::EarlyBinder::bind(ct)
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue