From 3ab066389bd7da10f67e2ae3234bab001a009e17 Mon Sep 17 00:00:00 2001 From: Oliver Scherer Date: Thu, 26 Dec 2019 17:28:07 +0100 Subject: [PATCH] Prevent polymorphic const prop on assignments --- src/librustc_mir/transform/const_prop.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/librustc_mir/transform/const_prop.rs b/src/librustc_mir/transform/const_prop.rs index 88b916424f155..ab43249692cf4 100644 --- a/src/librustc_mir/transform/const_prop.rs +++ b/src/librustc_mir/transform/const_prop.rs @@ -562,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)?;