about summary refs log tree commit diff
diff options
context:
space:
mode:
authorvarkor <github@varkor.com>2019-03-12 20:25:41 +0000
committervarkor <github@varkor.com>2019-05-01 23:10:57 +0100
commitf5712d2de09e2c35843150b05fdf3672534dff00 (patch)
tree2d2a3dce43974e79d411aa2ecd5deffdd0494a16
parent245a474ab7f782912255152e68a7e545718820bf (diff)
downloadrust-f5712d2de09e2c35843150b05fdf3672534dff00.tar.gz
rust-f5712d2de09e2c35843150b05fdf3672534dff00.zip
Add `ConstValue::Placeholder`
-rw-r--r--src/librustc/infer/canonical/canonicalizer.rs6
-rw-r--r--src/librustc/infer/freshen.rs3
-rw-r--r--src/librustc/mir/interpret/value.rs1
-rw-r--r--src/librustc/ty/flags.rs3
-rw-r--r--src/librustc/ty/fold.rs6
-rw-r--r--src/librustc/ty/mod.rs4
-rw-r--r--src/librustc/ty/relate.rs3
-rw-r--r--src/librustc_codegen_ssa/mir/operand.rs1
-rw-r--r--src/librustc_mir/interpret/operand.rs2
-rw-r--r--src/librustc_mir/monomorphize/item.rs2
10 files changed, 24 insertions, 7 deletions
diff --git a/src/librustc/infer/canonical/canonicalizer.rs b/src/librustc/infer/canonical/canonicalizer.rs
index 0fc13bdaee6..22e5767df33 100644
--- a/src/librustc/infer/canonical/canonicalizer.rs
+++ b/src/librustc/infer/canonical/canonicalizer.rs
@@ -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();
diff --git a/src/librustc/infer/freshen.rs b/src/librustc/infer/freshen.rs
index b43f78efffb..aa1a8636196 100644
--- a/src/librustc/infer/freshen.rs
+++ b/src/librustc/infer/freshen.rs
@@ -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)
                 }
 
diff --git a/src/librustc/mir/interpret/value.rs b/src/librustc/mir/interpret/value.rs
index 18c82ecd38e..12178196cef 100644
--- a/src/librustc/mir/interpret/value.rs
+++ b/src/librustc/mir/interpret/value.rs
@@ -58,6 +58,7 @@ impl<'tcx> ConstValue<'tcx> {
         match *self {
             ConstValue::Param(_) |
             ConstValue::Infer(_) |
+            ConstValue::Placeholder(_) |
             ConstValue::ByRef(..) |
             ConstValue::Unevaluated(..) |
             ConstValue::Slice(..) => None,
diff --git a/src/librustc/ty/flags.rs b/src/librustc/ty/flags.rs
index cb4724adc93..8d7e7e16e85 100644
--- a/src/librustc/ty/flags.rs
+++ b/src/librustc/ty/flags.rs
@@ -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);
+            }
             _ => {},
         }
     }
diff --git a/src/librustc/ty/fold.rs b/src/librustc/ty/fold.rs
index 13b5885f51d..5d3c71f3eab 100644
--- a/src/librustc/ty/fold.rs
+++ b/src/librustc/ty/fold.rs
@@ -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)
diff --git a/src/librustc/ty/mod.rs b/src/librustc/ty/mod.rs
index 6b938ea2fcc..09fd7f2e79a 100644
--- a/src/librustc/ty/mod.rs
+++ b/src/librustc/ty/mod.rs
@@ -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;
     }
 }
 
diff --git a/src/librustc/ty/relate.rs b/src/librustc/ty/relate.rs
index 5b5eb783f57..e60edfeba1c 100644
--- a/src/librustc/ty/relate.rs
+++ b/src/librustc/ty/relate.rs
@@ -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)
                 }
diff --git a/src/librustc_codegen_ssa/mir/operand.rs b/src/librustc_codegen_ssa/mir/operand.rs
index c2b1021f816..3b8e5b44953 100644
--- a/src/librustc_codegen_ssa/mir/operand.rs
+++ b/src/librustc_codegen_ssa/mir/operand.rs
@@ -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,
diff --git a/src/librustc_mir/interpret/operand.rs b/src/librustc_mir/interpret/operand.rs
index 55c1bfb17de..df6d4568ab3 100644
--- a/src/librustc_mir/interpret/operand.rs
+++ b/src/librustc_mir/interpret/operand.rs
@@ -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.
diff --git a/src/librustc_mir/monomorphize/item.rs b/src/librustc_mir/monomorphize/item.rs
index 2fc0e08834a..b001a09529e 100644
--- a/src/librustc_mir/monomorphize/item.rs
+++ b/src/librustc_mir/monomorphize/item.rs
@@ -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();
             }