Skip to content

Commit f5712d2

Browse files
committed
Add ConstValue::Placeholder
1 parent 245a474 commit f5712d2

File tree

10 files changed

+24
-7
lines changed

10 files changed

+24
-7
lines changed

src/librustc/infer/canonical/canonicalizer.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -499,11 +499,13 @@ impl<'cx, 'gcx, 'tcx> Canonicalizer<'cx, 'gcx, 'tcx> {
499499
let needs_canonical_flags = if canonicalize_region_mode.any() {
500500
TypeFlags::KEEP_IN_LOCAL_TCX |
501501
TypeFlags::HAS_FREE_REGIONS | // `HAS_RE_PLACEHOLDER` implies `HAS_FREE_REGIONS`
502-
TypeFlags::HAS_TY_PLACEHOLDER
502+
TypeFlags::HAS_TY_PLACEHOLDER |
503+
TypeFlags::HAS_CT_PLACEHOLDER
503504
} else {
504505
TypeFlags::KEEP_IN_LOCAL_TCX |
505506
TypeFlags::HAS_RE_PLACEHOLDER |
506-
TypeFlags::HAS_TY_PLACEHOLDER
507+
TypeFlags::HAS_TY_PLACEHOLDER |
508+
TypeFlags::HAS_CT_PLACEHOLDER
507509
};
508510

509511
let gcx = tcx.global_tcx();

src/librustc/infer/freshen.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,8 @@ impl<'a, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for TypeFreshener<'a, 'gcx, 'tcx> {
253253
return ct;
254254
}
255255

256-
ConstValue::Infer(ty::InferConst::Canonical(..)) => {
256+
ConstValue::Infer(ty::InferConst::Canonical(..)) |
257+
ConstValue::Placeholder(_) => {
257258
bug!("unexpected const {:?}", ct)
258259
}
259260

src/librustc/mir/interpret/value.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ impl<'tcx> ConstValue<'tcx> {
5858
match *self {
5959
ConstValue::Param(_) |
6060
ConstValue::Infer(_) |
61+
ConstValue::Placeholder(_) |
6162
ConstValue::ByRef(..) |
6263
ConstValue::Unevaluated(..) |
6364
ConstValue::Slice(..) => None,

src/librustc/ty/flags.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,9 @@ impl FlagComputation {
254254
ConstValue::Param(_) => {
255255
self.add_flags(TypeFlags::HAS_FREE_LOCAL_NAMES | TypeFlags::HAS_PARAMS);
256256
}
257+
ConstValue::Placeholder(_) => {
258+
self.add_flags(TypeFlags::HAS_FREE_REGIONS | TypeFlags::HAS_CT_PLACEHOLDER);
259+
}
257260
_ => {},
258261
}
259262
}

src/librustc/ty/fold.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,11 @@ pub trait TypeFoldable<'tcx>: fmt::Debug + Clone {
9797
)
9898
}
9999
fn has_placeholders(&self) -> bool {
100-
self.has_type_flags(TypeFlags::HAS_RE_PLACEHOLDER | TypeFlags::HAS_TY_PLACEHOLDER)
100+
self.has_type_flags(
101+
TypeFlags::HAS_RE_PLACEHOLDER |
102+
TypeFlags::HAS_TY_PLACEHOLDER |
103+
TypeFlags::HAS_CT_PLACEHOLDER
104+
)
101105
}
102106
fn needs_subst(&self) -> bool {
103107
self.has_type_flags(TypeFlags::NEEDS_SUBST)

src/librustc/ty/mod.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -455,6 +455,7 @@ bitflags! {
455455
const HAS_TY_PLACEHOLDER = 1 << 14;
456456

457457
const HAS_CT_INFER = 1 << 15;
458+
const HAS_CT_PLACEHOLDER = 1 << 16;
458459

459460
const NEEDS_SUBST = TypeFlags::HAS_PARAMS.bits |
460461
TypeFlags::HAS_SELF.bits |
@@ -477,7 +478,8 @@ bitflags! {
477478
TypeFlags::HAS_FREE_LOCAL_NAMES.bits |
478479
TypeFlags::KEEP_IN_LOCAL_TCX.bits |
479480
TypeFlags::HAS_RE_LATE_BOUND.bits |
480-
TypeFlags::HAS_TY_PLACEHOLDER.bits;
481+
TypeFlags::HAS_TY_PLACEHOLDER.bits |
482+
TypeFlags::HAS_CT_PLACEHOLDER.bits;
481483
}
482484
}
483485

src/librustc/ty/relate.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -615,6 +615,9 @@ where
615615
(ConstValue::Param(a_p), ConstValue::Param(b_p)) if a_p.index == b_p.index => {
616616
Ok(a)
617617
}
618+
(ConstValue::Placeholder(p1), ConstValue::Placeholder(p2)) if p1 == p2 => {
619+
Ok(a)
620+
}
618621
(ConstValue::Scalar(Scalar::Bits { .. }), _) if a == b => {
619622
Ok(a)
620623
}

src/librustc_codegen_ssa/mir/operand.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ impl<'a, 'tcx: 'a, V: CodegenObject> OperandRef<'tcx, V> {
7979
ConstValue::Unevaluated(..) => bug!("unevaluated constant in `OperandRef::from_const`"),
8080
ConstValue::Param(_) => bug!("encountered a ConstValue::Param in codegen"),
8181
ConstValue::Infer(_) => bug!("encountered a ConstValue::Infer in codegen"),
82+
ConstValue::Placeholder(_) => bug!("encountered a ConstValue::Placeholder in codegen"),
8283
ConstValue::Scalar(x) => {
8384
let scalar = match layout.abi {
8485
layout::Abi::Scalar(ref x) => x,

src/librustc_mir/interpret/operand.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -524,7 +524,7 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> InterpretCx<'a, 'mir, 'tcx, M>
524524
layout: Option<TyLayout<'tcx>>,
525525
) -> EvalResult<'tcx, OpTy<'tcx, M::PointerTag>> {
526526
let op = match val.val {
527-
ConstValue::Param(_) | ConstValue::Infer(_) => bug!(),
527+
ConstValue::Param(_) | ConstValue::Infer(_) | ConstValue::Placeholder(_) => bug!(),
528528
ConstValue::ByRef(ptr, alloc) => {
529529
// We rely on mutability being set correctly in that allocation to prevent writes
530530
// where none should happen -- and for `static mut`, we copy on demand anyway.

src/librustc_mir/monomorphize/item.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,7 @@ impl<'a, 'tcx> DefPathBasedNames<'a, 'tcx> {
397397
// FIXME(const_generics): handle debug printing.
398398
pub fn push_const_name(&self, c: &Const<'tcx>, output: &mut String, debug: bool) {
399399
match c.val {
400-
ConstValue::Infer(..) => output.push_str("_"),
400+
ConstValue::Infer(..) | ConstValue::Placeholder(_) => output.push_str("_"),
401401
ConstValue::Param(ParamConst { name, .. }) => {
402402
write!(output, "{}", name).unwrap();
403403
}

0 commit comments

Comments
 (0)