Skip to content

Commit cc05dfe

Browse files
committed
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.
1 parent e36c186 commit cc05dfe

File tree

2 files changed

+1
-28
lines changed

2 files changed

+1
-28
lines changed

src/librustc_mir/hair/cx/expr.rs

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -712,19 +712,7 @@ fn convert_path_expr<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>,
712712
ref sty => bug!("unexpected sty: {:?}", sty)
713713
},
714714
Def::Const(def_id) |
715-
Def::AssociatedConst(def_id) => {
716-
let substs = Some(cx.tcx.node_id_item_substs(expr.id).substs);
717-
let tcx = cx.tcx.global_tcx();
718-
if let Some((e, _)) = const_eval::lookup_const_by_id(tcx, def_id, substs) {
719-
// FIXME ConstVal can't be yet used with adjustments, as they would be lost.
720-
if !cx.tcx.tables.borrow().adjustments.contains_key(&e.id) {
721-
if let Some(v) = cx.try_const_eval_literal(e) {
722-
return ExprKind::Literal { literal: v };
723-
}
724-
}
725-
}
726-
def_id
727-
}
715+
Def::AssociatedConst(def_id) => def_id,
728716

729717
Def::Static(node_id, _) => return ExprKind::StaticRef {
730718
id: node_id,

src/librustc_mir/hair/cx/mod.rs

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -90,21 +90,6 @@ impl<'a, 'gcx, 'tcx> Cx<'a, 'gcx, 'tcx> {
9090
}
9191
}
9292

93-
pub fn try_const_eval_literal(&mut self, e: &hir::Expr) -> Option<Literal<'tcx>> {
94-
let hint = const_eval::EvalHint::ExprTypeChecked;
95-
let tcx = self.tcx.global_tcx();
96-
const_eval::eval_const_expr_partial(tcx, e, hint, None).ok().and_then(|v| {
97-
match v {
98-
// All of these contain local IDs, unsuitable for storing in MIR.
99-
ConstVal::Struct(_) | ConstVal::Tuple(_) |
100-
ConstVal::Array(..) | ConstVal::Repeat(..) |
101-
ConstVal::Function(_) => None,
102-
103-
_ => Some(Literal::Value { value: v })
104-
}
105-
})
106-
}
107-
10893
pub fn trait_method(&mut self,
10994
trait_def_id: DefId,
11095
method_name: &str,

0 commit comments

Comments
 (0)