diff --git a/src/librustc_mir/interpret/intern.rs b/src/librustc_mir/interpret/intern.rs index 02a7f24a1e351..4c1cf1b56ae66 100644 --- a/src/librustc_mir/interpret/intern.rs +++ b/src/librustc_mir/interpret/intern.rs @@ -294,7 +294,6 @@ pub enum InternKind { Static(hir::Mutability), Constant, Promoted, - ConstProp, } /// Intern `ret` and everything it references. @@ -315,9 +314,7 @@ pub fn intern_const_alloc_recursive>( let base_intern_mode = match intern_kind { InternKind::Static(mutbl) => InternMode::Static(mutbl), // FIXME: what about array lengths, array initializers? - InternKind::Constant | InternKind::ConstProp | InternKind::Promoted => { - InternMode::ConstBase - } + InternKind::Constant | InternKind::Promoted => InternMode::ConstBase, }; // Type based interning. @@ -359,7 +356,10 @@ pub fn intern_const_alloc_recursive>( Err(error) => { ecx.tcx.sess.delay_span_bug( ecx.tcx.span, - "error during interning should later cause validation failure", + &format!( + "error during interning should later cause validation failure: {}", + error + ), ); // Some errors shouldn't come up because creating them causes // an allocation, which we should avoid. When that happens, @@ -400,7 +400,7 @@ pub fn intern_const_alloc_recursive>( // immutability is so important. alloc.mutability = Mutability::Not; } - InternKind::Constant | InternKind::ConstProp => { + InternKind::Constant => { // If it's a constant, we should not have any "leftovers" as everything // is tracked by const-checking. // FIXME: downgrade this to a warning? It rejects some legitimate consts, diff --git a/src/librustc_mir/transform/const_prop.rs b/src/librustc_mir/transform/const_prop.rs index 92000e6411354..97e5b8bc047f0 100644 --- a/src/librustc_mir/transform/const_prop.rs +++ b/src/librustc_mir/transform/const_prop.rs @@ -27,9 +27,9 @@ use rustc_trait_selection::traits; use crate::const_eval::error_to_const_error; use crate::interpret::{ - self, compile_time_machine, intern_const_alloc_recursive, AllocId, Allocation, Frame, ImmTy, - Immediate, InternKind, InterpCx, LocalState, LocalValue, Memory, MemoryKind, OpTy, - Operand as InterpOperand, PlaceTy, Pointer, ScalarMaybeUninit, StackPopCleanup, + self, compile_time_machine, AllocId, Allocation, Frame, ImmTy, Immediate, InterpCx, LocalState, + LocalValue, Memory, MemoryKind, OpTy, Operand as InterpOperand, PlaceTy, Pointer, + ScalarMaybeUninit, StackPopCleanup, }; use crate::transform::{MirPass, MirSource}; @@ -707,11 +707,7 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> { ScalarMaybeUninit::Scalar(l), ScalarMaybeUninit::Scalar(r), )) => l.is_bits() && r.is_bits(), - interpret::Operand::Indirect(_) if mir_opt_level >= 2 => { - let mplace = op.assert_mem_place(&self.ecx); - intern_const_alloc_recursive(&mut self.ecx, InternKind::ConstProp, mplace, false); - true - } + interpret::Operand::Indirect(_) if mir_opt_level >= 2 => true, _ => false, } }