about summary refs log tree commit diff
diff options
context:
space:
mode:
authorvarkor <github@varkor.com>2019-03-05 22:49:37 +0000
committervarkor <github@varkor.com>2019-03-05 22:49:37 +0000
commited9227abbdb14728777691c0d595a93c57a796bf (patch)
tree8e468f8e02e737ac30b25d43d09b2b6cc2a6f356
parent5c8b3c38f1a5a0270b29fa01f14c9db0b255ea43 (diff)
downloadrust-ed9227abbdb14728777691c0d595a93c57a796bf.tar.gz
rust-ed9227abbdb14728777691c0d595a93c57a796bf.zip
Make adjustments for comments
-rw-r--r--src/librustc_mir/interpret/operand.rs8
-rw-r--r--src/librustc_mir/monomorphize/collector.rs13
2 files changed, 12 insertions, 9 deletions
diff --git a/src/librustc_mir/interpret/operand.rs b/src/librustc_mir/interpret/operand.rs
index 11b4aa17ec4..1ebff411510 100644
--- a/src/librustc_mir/interpret/operand.rs
+++ b/src/librustc_mir/interpret/operand.rs
@@ -593,9 +593,13 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M>
             let ty = self.monomorphize(val.ty)?;
             self.layout_of(ty)
         })?;
-        let op = match val.val {
-            ConstValue::Param(_) => return Err(EvalErrorKind::TooGeneric.into()),
+        let val = match val.val {
+            ConstValue::Param(_) => self.monomorphize(val)?.val,
             ConstValue::Infer(_) => bug!(),
+            val => val,
+        };
+        let op = match val {
+            ConstValue::Param(_) | ConstValue::Infer(_) => unreachable!(),
             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/collector.rs b/src/librustc_mir/monomorphize/collector.rs
index 2ce3bf43cfc..4350bfcdc7a 100644
--- a/src/librustc_mir/monomorphize/collector.rs
+++ b/src/librustc_mir/monomorphize/collector.rs
@@ -467,14 +467,13 @@ fn check_type_length_limit<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
 {
     let type_length = instance.substs.types().flat_map(|ty| ty.walk()).count();
     let const_length = instance.substs.consts()
-        .filter_map(|ct| {
-            if let ty::LazyConst::Evaluated(ct) = ct {
-                Some(ct.ty.walk())
-            } else {
-                None
-            }
+        .flat_map(|ct| {
+            let ty = match ct {
+                ty::LazyConst::Evaluated(ct) => ct.ty,
+                ty::LazyConst::Unevaluated(def_id, _) => tcx.type_of(*def_id),
+            };
+            ty.walk()
         })
-        .flatten()
         .count();
     debug!(" => type length={}, const length={}", type_length, const_length);