Skip to content

Commit

Permalink
Work around a resolve bug in const prop
Browse files Browse the repository at this point in the history
  • Loading branch information
oli-obk committed Dec 26, 2019
1 parent acb6690 commit 652cec1
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/librustc_mir/transform/const_prop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use rustc::ty::layout::{
HasDataLayout, HasTyCtxt, LayoutError, LayoutOf, Size, TargetDataLayout, TyLayout,
};
use rustc::ty::subst::InternalSubsts;
use rustc::ty::{self, Instance, ParamEnv, Ty, TyCtxt};
use rustc::ty::{self, Instance, ParamEnv, Ty, TyCtxt, TypeFoldable};
use rustc_data_structures::fx::FxHashMap;
use rustc_index::vec::IndexVec;
use syntax::ast::Mutability;
Expand Down Expand Up @@ -410,6 +410,12 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> {
}

fn eval_constant(&mut self, c: &Constant<'tcx>) -> Option<Const<'tcx>> {
// `eval_const_to_op` uses `Instance::resolve` which still has a bug (#66901) in the
// presence of trait items with a default body. So we just bail out if we aren't 100%
// monomorphic.
if c.literal.needs_subst() {
return None;
}
self.ecx.tcx.span = c.span;
match self.ecx.eval_const_to_op(c.literal, None) {
Ok(op) => Some(op),
Expand Down

0 comments on commit 652cec1

Please sign in to comment.