Skip to content

Commit 652cec1

Browse files
committed
Work around a resolve bug in const prop
1 parent acb6690 commit 652cec1

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/librustc_mir/transform/const_prop.rs

+7-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ use rustc::ty::layout::{
2020
HasDataLayout, HasTyCtxt, LayoutError, LayoutOf, Size, TargetDataLayout, TyLayout,
2121
};
2222
use rustc::ty::subst::InternalSubsts;
23-
use rustc::ty::{self, Instance, ParamEnv, Ty, TyCtxt};
23+
use rustc::ty::{self, Instance, ParamEnv, Ty, TyCtxt, TypeFoldable};
2424
use rustc_data_structures::fx::FxHashMap;
2525
use rustc_index::vec::IndexVec;
2626
use syntax::ast::Mutability;
@@ -410,6 +410,12 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> {
410410
}
411411

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

0 commit comments

Comments
 (0)