Overhaul Const.
Specifically, rename the `Const` struct as `ConstS` and re-introduce `Const` as this: ``` pub struct Const<'tcx>(&'tcx Interned<ConstS>); ``` This now matches `Ty` and `Predicate` more closely, including using pointer-based `eq` and `hash`. Notable changes: - `mk_const` now takes a `ConstS`. - `Const` was copy, despite being 48 bytes. Now `ConstS` is not, so need a we need separate arena for it, because we can't use the `Dropless` one any more. - Many `&'tcx Const<'tcx>`/`&Const<'tcx>` to `Const<'tcx>` changes - Many `ct.ty` to `ct.ty()` and `ct.val` to `ct.val()` changes. - Lots of tedious sigil fiddling.
This commit is contained in:
@@ -29,7 +29,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
|
||||
mir::ConstantKind::Ty(ct) => ct,
|
||||
mir::ConstantKind::Val(val, _) => return Ok(val),
|
||||
};
|
||||
match ct.val {
|
||||
match ct.val() {
|
||||
ty::ConstKind::Unevaluated(ct) => self
|
||||
.cx
|
||||
.tcx()
|
||||
@@ -61,11 +61,11 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
|
||||
let c = ty::Const::from_value(bx.tcx(), val, ty);
|
||||
let values: Vec<_> = bx
|
||||
.tcx()
|
||||
.destructure_const(ty::ParamEnv::reveal_all().and(&c))
|
||||
.destructure_const(ty::ParamEnv::reveal_all().and(c))
|
||||
.fields
|
||||
.iter()
|
||||
.map(|field| {
|
||||
if let Some(prim) = field.val.try_to_scalar() {
|
||||
if let Some(prim) = field.val().try_to_scalar() {
|
||||
let layout = bx.layout_of(field_ty);
|
||||
let scalar = match layout.abi {
|
||||
Abi::Scalar(x) => x,
|
||||
@@ -78,7 +78,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
|
||||
})
|
||||
.collect();
|
||||
let llval = bx.const_struct(&values, false);
|
||||
(llval, c.ty)
|
||||
(llval, c.ty())
|
||||
})
|
||||
.unwrap_or_else(|_| {
|
||||
bx.tcx().sess.span_err(span, "could not evaluate shuffle_indices at compile time");
|
||||
|
||||
Reference in New Issue
Block a user