Add ConstValue::Placeholder
This commit is contained in:
parent
245a474ab7
commit
f5712d2de0
10 changed files with 24 additions and 7 deletions
|
@ -499,11 +499,13 @@ impl<'cx, 'gcx, 'tcx> Canonicalizer<'cx, 'gcx, 'tcx> {
|
|||
let needs_canonical_flags = if canonicalize_region_mode.any() {
|
||||
TypeFlags::KEEP_IN_LOCAL_TCX |
|
||||
TypeFlags::HAS_FREE_REGIONS | // `HAS_RE_PLACEHOLDER` implies `HAS_FREE_REGIONS`
|
||||
TypeFlags::HAS_TY_PLACEHOLDER
|
||||
TypeFlags::HAS_TY_PLACEHOLDER |
|
||||
TypeFlags::HAS_CT_PLACEHOLDER
|
||||
} else {
|
||||
TypeFlags::KEEP_IN_LOCAL_TCX |
|
||||
TypeFlags::HAS_RE_PLACEHOLDER |
|
||||
TypeFlags::HAS_TY_PLACEHOLDER
|
||||
TypeFlags::HAS_TY_PLACEHOLDER |
|
||||
TypeFlags::HAS_CT_PLACEHOLDER
|
||||
};
|
||||
|
||||
let gcx = tcx.global_tcx();
|
||||
|
|
|
@ -253,7 +253,8 @@ impl<'a, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for TypeFreshener<'a, 'gcx, 'tcx> {
|
|||
return ct;
|
||||
}
|
||||
|
||||
ConstValue::Infer(ty::InferConst::Canonical(..)) => {
|
||||
ConstValue::Infer(ty::InferConst::Canonical(..)) |
|
||||
ConstValue::Placeholder(_) => {
|
||||
bug!("unexpected const {:?}", ct)
|
||||
}
|
||||
|
||||
|
|
|
@ -58,6 +58,7 @@ impl<'tcx> ConstValue<'tcx> {
|
|||
match *self {
|
||||
ConstValue::Param(_) |
|
||||
ConstValue::Infer(_) |
|
||||
ConstValue::Placeholder(_) |
|
||||
ConstValue::ByRef(..) |
|
||||
ConstValue::Unevaluated(..) |
|
||||
ConstValue::Slice(..) => None,
|
||||
|
|
|
@ -254,6 +254,9 @@ impl FlagComputation {
|
|||
ConstValue::Param(_) => {
|
||||
self.add_flags(TypeFlags::HAS_FREE_LOCAL_NAMES | TypeFlags::HAS_PARAMS);
|
||||
}
|
||||
ConstValue::Placeholder(_) => {
|
||||
self.add_flags(TypeFlags::HAS_FREE_REGIONS | TypeFlags::HAS_CT_PLACEHOLDER);
|
||||
}
|
||||
_ => {},
|
||||
}
|
||||
}
|
||||
|
|
|
@ -97,7 +97,11 @@ pub trait TypeFoldable<'tcx>: fmt::Debug + Clone {
|
|||
)
|
||||
}
|
||||
fn has_placeholders(&self) -> bool {
|
||||
self.has_type_flags(TypeFlags::HAS_RE_PLACEHOLDER | TypeFlags::HAS_TY_PLACEHOLDER)
|
||||
self.has_type_flags(
|
||||
TypeFlags::HAS_RE_PLACEHOLDER |
|
||||
TypeFlags::HAS_TY_PLACEHOLDER |
|
||||
TypeFlags::HAS_CT_PLACEHOLDER
|
||||
)
|
||||
}
|
||||
fn needs_subst(&self) -> bool {
|
||||
self.has_type_flags(TypeFlags::NEEDS_SUBST)
|
||||
|
|
|
@ -455,6 +455,7 @@ bitflags! {
|
|||
const HAS_TY_PLACEHOLDER = 1 << 14;
|
||||
|
||||
const HAS_CT_INFER = 1 << 15;
|
||||
const HAS_CT_PLACEHOLDER = 1 << 16;
|
||||
|
||||
const NEEDS_SUBST = TypeFlags::HAS_PARAMS.bits |
|
||||
TypeFlags::HAS_SELF.bits |
|
||||
|
@ -477,7 +478,8 @@ bitflags! {
|
|||
TypeFlags::HAS_FREE_LOCAL_NAMES.bits |
|
||||
TypeFlags::KEEP_IN_LOCAL_TCX.bits |
|
||||
TypeFlags::HAS_RE_LATE_BOUND.bits |
|
||||
TypeFlags::HAS_TY_PLACEHOLDER.bits;
|
||||
TypeFlags::HAS_TY_PLACEHOLDER.bits |
|
||||
TypeFlags::HAS_CT_PLACEHOLDER.bits;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -615,6 +615,9 @@ where
|
|||
(ConstValue::Param(a_p), ConstValue::Param(b_p)) if a_p.index == b_p.index => {
|
||||
Ok(a)
|
||||
}
|
||||
(ConstValue::Placeholder(p1), ConstValue::Placeholder(p2)) if p1 == p2 => {
|
||||
Ok(a)
|
||||
}
|
||||
(ConstValue::Scalar(Scalar::Bits { .. }), _) if a == b => {
|
||||
Ok(a)
|
||||
}
|
||||
|
|
|
@ -79,6 +79,7 @@ impl<'a, 'tcx: 'a, V: CodegenObject> OperandRef<'tcx, V> {
|
|||
ConstValue::Unevaluated(..) => bug!("unevaluated constant in `OperandRef::from_const`"),
|
||||
ConstValue::Param(_) => bug!("encountered a ConstValue::Param in codegen"),
|
||||
ConstValue::Infer(_) => bug!("encountered a ConstValue::Infer in codegen"),
|
||||
ConstValue::Placeholder(_) => bug!("encountered a ConstValue::Placeholder in codegen"),
|
||||
ConstValue::Scalar(x) => {
|
||||
let scalar = match layout.abi {
|
||||
layout::Abi::Scalar(ref x) => x,
|
||||
|
|
|
@ -524,7 +524,7 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> InterpretCx<'a, 'mir, 'tcx, M>
|
|||
layout: Option<TyLayout<'tcx>>,
|
||||
) -> EvalResult<'tcx, OpTy<'tcx, M::PointerTag>> {
|
||||
let op = match val.val {
|
||||
ConstValue::Param(_) | ConstValue::Infer(_) => bug!(),
|
||||
ConstValue::Param(_) | ConstValue::Infer(_) | ConstValue::Placeholder(_) => bug!(),
|
||||
ConstValue::ByRef(ptr, alloc) => {
|
||||
// We rely on mutability being set correctly in that allocation to prevent writes
|
||||
// where none should happen -- and for `static mut`, we copy on demand anyway.
|
||||
|
|
|
@ -397,7 +397,7 @@ impl<'a, 'tcx> DefPathBasedNames<'a, 'tcx> {
|
|||
// FIXME(const_generics): handle debug printing.
|
||||
pub fn push_const_name(&self, c: &Const<'tcx>, output: &mut String, debug: bool) {
|
||||
match c.val {
|
||||
ConstValue::Infer(..) => output.push_str("_"),
|
||||
ConstValue::Infer(..) | ConstValue::Placeholder(_) => output.push_str("_"),
|
||||
ConstValue::Param(ParamConst { name, .. }) => {
|
||||
write!(output, "{}", name).unwrap();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue