implement valtrees as the type-system representation for constant values
This commit is contained in:
parent
edab34ab2a
commit
705d818bd5
116 changed files with 1606 additions and 1032 deletions
|
@ -38,7 +38,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
|
|||
self.cx.tcx().sess.span_err(constant.span, "erroneous constant encountered");
|
||||
err
|
||||
}),
|
||||
ty::ConstKind::Value(value) => Ok(value),
|
||||
ty::ConstKind::Value(val) => Ok(self.cx.tcx().valtree_to_const_val((ct.ty(), val))),
|
||||
err => span_bug!(
|
||||
constant.span,
|
||||
"encountered bad ConstKind after monomorphizing: {:?}",
|
||||
|
@ -58,14 +58,14 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
|
|||
constant
|
||||
.map(|val| {
|
||||
let field_ty = ty.builtin_index().unwrap();
|
||||
let c = ty::Const::from_value(bx.tcx(), val, ty);
|
||||
let c = mir::ConstantKind::from_value(val, ty);
|
||||
let values: Vec<_> = bx
|
||||
.tcx()
|
||||
.destructure_const(ty::ParamEnv::reveal_all().and(c))
|
||||
.destructure_mir_constant(ty::ParamEnv::reveal_all(), c)
|
||||
.fields
|
||||
.iter()
|
||||
.map(|field| {
|
||||
if let Some(prim) = field.kind().try_to_scalar() {
|
||||
if let Some(prim) = field.try_to_scalar() {
|
||||
let layout = bx.layout_of(field_ty);
|
||||
let Abi::Scalar(scalar) = layout.abi else {
|
||||
bug!("from_const: invalid ByVal layout: {:#?}", layout);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue