From 13694de4a260e461bd832bd7bc09eb7c3a367c2a Mon Sep 17 00:00:00 2001 From: Oliver Scherer Date: Sat, 14 Dec 2019 00:05:28 +0100 Subject: [PATCH] Comment on a few odd things that we should look at --- src/librustc_mir/interpret/eval_context.rs | 2 ++ src/librustc_mir/interpret/operand.rs | 7 ++----- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/librustc_mir/interpret/eval_context.rs b/src/librustc_mir/interpret/eval_context.rs index 5ba9dcd3aa5c..7a26857c560e 100644 --- a/src/librustc_mir/interpret/eval_context.rs +++ b/src/librustc_mir/interpret/eval_context.rs @@ -761,6 +761,8 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> { // FIXME(oli-obk): make this check an assertion that it's not a static here // FIXME(RalfJ, oli-obk): document that `Place::Static` can never be anything but a static // and `ConstValue::Unevaluated` can never be a static + // FIXME(oli-obk, spastorino): the above FIXME is not true anymore, PlaceBase::Static does + // not exist anymore (except for promoteds but it's going away soon). let param_env = if self.tcx.is_static(gid.instance.def_id()) { ty::ParamEnv::reveal_all() } else { diff --git a/src/librustc_mir/interpret/operand.rs b/src/librustc_mir/interpret/operand.rs index a89abe71c654..82974f338d2a 100644 --- a/src/librustc_mir/interpret/operand.rs +++ b/src/librustc_mir/interpret/operand.rs @@ -578,13 +578,10 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> { ty::ConstKind::Param(_) => throw_inval!(TooGeneric), ty::ConstKind::Unevaluated(def_id, substs) => { let instance = self.resolve(def_id, substs)?; + // FIXME: don't use `const_eval_raw` for regular constants, instead use `const_eval` + // which immediately validates the result before we continue with it here. return Ok(OpTy::from(self.const_eval_raw(GlobalId { instance, promoted: None })?)); } - ty::ConstKind::Infer(..) - | ty::ConstKind::Bound(..) - | ty::ConstKind::Placeholder(..) => { - bug!("eval_const_to_op: Unexpected ConstKind {:?}", val) - } ty::ConstKind::Value(val_val) => val_val, }; // Other cases need layout.