implement valtrees as the type-system representation for constant values

This commit is contained in:
b-naber 2022-02-16 10:56:01 +01:00
parent edab34ab2a
commit 705d818bd5
116 changed files with 1606 additions and 1032 deletions

View file

@ -3,8 +3,8 @@
use crate::MirPass;
use rustc_hir::Mutability;
use rustc_middle::mir::{
BinOp, Body, Constant, LocalDecls, Operand, Place, ProjectionElem, Rvalue, SourceInfo,
Statement, StatementKind, Terminator, TerminatorKind, UnOp,
BinOp, Body, Constant, ConstantKind, LocalDecls, Operand, Place, ProjectionElem, Rvalue,
SourceInfo, Statement, StatementKind, Terminator, TerminatorKind, UnOp,
};
use rustc_middle::ty::{self, TyCtxt};
@ -129,8 +129,8 @@ impl<'tcx> InstCombineContext<'tcx, '_> {
return;
}
let constant =
Constant { span: source_info.span, literal: len.into(), user_ty: None };
let literal = ConstantKind::from_const(len, self.tcx);
let constant = Constant { span: source_info.span, literal, user_ty: None };
*rvalue = Rvalue::Use(Operand::Constant(Box::new(constant)));
}
}