diff options
| author | Oliver Schneider <git-spam-no-reply9815368754983@oli-obk.de> | 2016-04-29 14:40:08 +0200 |
|---|---|---|
| committer | Oliver Schneider <git-spam-no-reply9815368754983@oli-obk.de> | 2016-07-05 08:20:02 +0200 |
| commit | e7b083aeae0392bc1b79a7dcd71c002a2ac22a23 (patch) | |
| tree | 78b5766f30bc2b2e54b3d4fcbfb18506a2cd6a75 | |
| parent | 0f4c4f8c2910d717044a041039a1a1aa914ff59e (diff) | |
| download | rust-e7b083aeae0392bc1b79a7dcd71c002a2ac22a23.tar.gz rust-e7b083aeae0392bc1b79a7dcd71c002a2ac22a23.zip | |
don't const eval constants during MIR creation
this didn't work very well anyway, because const_eval can't eval all kinds of constants.
| -rw-r--r-- | src/librustc_mir/hair/cx/expr.rs | 14 | ||||
| -rw-r--r-- | src/librustc_mir/hair/cx/mod.rs | 15 |
2 files changed, 1 insertions, 28 deletions
diff --git a/src/librustc_mir/hair/cx/expr.rs b/src/librustc_mir/hair/cx/expr.rs index b5e2ce9de48..88fb65d8eea 100644 --- a/src/librustc_mir/hair/cx/expr.rs +++ b/src/librustc_mir/hair/cx/expr.rs @@ -700,19 +700,7 @@ fn convert_path_expr<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>, ref sty => bug!("unexpected sty: {:?}", sty) }, Def::Const(def_id) | - Def::AssociatedConst(def_id) => { - let substs = Some(cx.tcx.node_id_item_substs(expr.id).substs); - let tcx = cx.tcx.global_tcx(); - if let Some((e, _)) = const_eval::lookup_const_by_id(tcx, def_id, substs) { - // FIXME ConstVal can't be yet used with adjustments, as they would be lost. - if !cx.tcx.tables.borrow().adjustments.contains_key(&e.id) { - if let Some(v) = cx.try_const_eval_literal(e) { - return ExprKind::Literal { literal: v }; - } - } - } - def_id - } + Def::AssociatedConst(def_id) => def_id, Def::Static(node_id, _) => return ExprKind::StaticRef { id: node_id, diff --git a/src/librustc_mir/hair/cx/mod.rs b/src/librustc_mir/hair/cx/mod.rs index 81b098281d6..2438f43d24e 100644 --- a/src/librustc_mir/hair/cx/mod.rs +++ b/src/librustc_mir/hair/cx/mod.rs @@ -129,21 +129,6 @@ impl<'a, 'gcx, 'tcx> Cx<'a, 'gcx, 'tcx> { } } - pub fn try_const_eval_literal(&mut self, e: &hir::Expr) -> Option<Literal<'tcx>> { - let hint = const_eval::EvalHint::ExprTypeChecked; - let tcx = self.tcx.global_tcx(); - const_eval::eval_const_expr_partial(tcx, e, hint, None).ok().and_then(|v| { - match v { - // All of these contain local IDs, unsuitable for storing in MIR. - ConstVal::Struct(_) | ConstVal::Tuple(_) | - ConstVal::Array(..) | ConstVal::Repeat(..) | - ConstVal::Function(_) => None, - - _ => Some(Literal::Value { value: v }) - } - }) - } - pub fn trait_method(&mut self, trait_def_id: DefId, method_name: &str, |
