diff options
| author | Oliver Scherer <github35764891676564198441@oli-obk.de> | 2019-12-26 15:10:13 +0100 |
|---|---|---|
| committer | Oliver Scherer <github35764891676564198441@oli-obk.de> | 2019-12-28 00:22:16 +0100 |
| commit | 3eb0585173deb61ed0ed3e15fad360882d894568 (patch) | |
| tree | 8181a2bbab428c239f0713b88189a743fa99fecc /src/librustc_mir/transform | |
| parent | 25a8b5d58e3899084e191ffd9456f39d29c3263b (diff) | |
| download | rust-3eb0585173deb61ed0ed3e15fad360882d894568.tar.gz rust-3eb0585173deb61ed0ed3e15fad360882d894568.zip | |
Work around a resolve bug in const prop
Diffstat (limited to 'src/librustc_mir/transform')
| -rw-r--r-- | src/librustc_mir/transform/const_prop.rs | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/librustc_mir/transform/const_prop.rs b/src/librustc_mir/transform/const_prop.rs index 62717daed16..bf8e63ebe3d 100644 --- a/src/librustc_mir/transform/const_prop.rs +++ b/src/librustc_mir/transform/const_prop.rs @@ -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; @@ -418,6 +418,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), |
