Store a LocalDefId in hir::AnonConst.

This commit is contained in:
Camille GILLOT
2022-11-06 19:17:57 +00:00
parent 18482f7b23
commit 607d0c2a14
12 changed files with 49 additions and 56 deletions

View File

@@ -432,7 +432,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
ty::Const::from_opt_const_arg_anon_const(
tcx,
ty::WithOptConstParam {
did: tcx.hir().local_def_id(ct.value.hir_id),
did: ct.value.def_id,
const_param_did: Some(param.def_id),
},
)
@@ -570,8 +570,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
ConvertedBindingKind::Equality(self.ast_ty_to_ty(ty).into())
}
hir::Term::Const(ref c) => {
let local_did = self.tcx().hir().local_def_id(c.hir_id);
let c = Const::from_anon_const(self.tcx(), local_did);
let c = Const::from_anon_const(self.tcx(), c.def_id);
ConvertedBindingKind::Equality(c.into())
}
},
@@ -2712,8 +2711,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
let length = match length {
&hir::ArrayLen::Infer(_, span) => self.ct_infer(tcx.types.usize, None, span),
hir::ArrayLen::Body(constant) => {
let length_def_id = tcx.hir().local_def_id(constant.hir_id);
ty::Const::from_anon_const(tcx, length_def_id)
ty::Const::from_anon_const(tcx, constant.def_id)
}
};
@@ -2721,7 +2719,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
self.normalize_ty(ast_ty.span, array_ty)
}
hir::TyKind::Typeof(ref e) => {
let ty_erased = tcx.type_of(tcx.hir().local_def_id(e.hir_id));
let ty_erased = tcx.type_of(e.def_id);
let ty = tcx.fold_regions(ty_erased, |r, _| {
if r.is_erased() { tcx.lifetimes.re_static } else { r }
});