Skip to content

Commit

Permalink
Rollup merge of rust-lang#67631 - oli-obk:polymorphic_promotion, r=we…
Browse files Browse the repository at this point in the history
…sleywiser

Work around a resolve bug in const prop

r? @wesleywiser @anp

This isn't exposed right now, but further changes to rustc may start causing bugs without this.
  • Loading branch information
JohnTitor authored Dec 27, 2019
2 parents bdaca98 + 3ab0663 commit 9f5259a
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 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 Expand Up @@ -556,6 +562,13 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> {
_ => {}
}

// `eval_rvalue_into_place` uses `Instance::resolve` for constants 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 rvalue.needs_subst() {
return None;
}

self.use_ecx(source_info, |this| {
trace!("calling eval_rvalue_into_place(rvalue = {:?}, place = {:?})", rvalue, place);
this.ecx.eval_rvalue_into_place(rvalue, place)?;
Expand Down

0 comments on commit 9f5259a

Please sign in to comment.