Change:
<!-- Thank you for finding an Internal Compiler Error! If possible, try to provide a minimal verifiable example. You can read "Rust Bug Minimization Patterns" for how to create smaller examples. --code from ./src/test/ui/consts/constconstructor/const-construct- <!-- If you're using the stable version of the compiler, you should also check if the bug also exists in the beta or nightly versions. --rustc @ <!-- Include a backtrace in the code block by setting in your environment. E.g. . --<details<summary<strongBacktrace</strong</summary<p</p</details
Might be caused by That should have reduced the number of ICEs, not increased it, but who knows.^^

Discussion:
Static(hir::Mutability), Constant, Promoted, <del> ConstProp, </del> } /// Intern `ret` and everything it references.

let base_intern_mode = match intern_kind { InternKind::Static(mutbl) => InternMode::Static(mutbl), // FIXME: what about array lengths, array initializers? <del> InternKind::Constant | InternKind::ConstProp | InternKind::Promoted => { InternMode::ConstBase } </del> <ins> InternKind::Constant | InternKind::Promoted => InternMode::ConstBase, </ins> }; // Type based interning.

Err(error) => { ecx.tcx.sess.delay_span_bug( ecx.tcx.span, <del> "error during interning should later cause validation failure", </del> <ins> &format!( "error during interning should later cause validation failure: {}", error ), </ins> ); // Some errors shouldn't come up because creating them causes // an allocation, which we should avoid. When that happens,

// immutability is so important. alloc.mutability = Mutability::Not; } <del> InternKind::Constant | InternKind::ConstProp => { </del> <ins> InternKind::Constant => { </ins> // 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,

use crate::const_eval::error_to_const_error; use crate::interpret::{ <del> 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, </del> <ins> self, compile_time_machine, AllocId, Allocation, Frame, ImmTy, Immediate, InterpCx, LocalState, LocalValue, Memory, MemoryKind, OpTy, Operand as InterpOperand, PlaceTy, Pointer, ScalarMaybeUninit, StackPopCleanup, </ins> }; use crate::transform::{MirPass, MirSource};

ScalarMaybeUninit::Scalar(l), ScalarMaybeUninit::Scalar(r), )) => l.is_bits() && r.is_bits(), <del> 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 } </del> _ => false, } }

// compile-flags: -O <ins> // FIXME(wesleywiser): Ideally, we could const-prop away all of this and just be left with // `let x = 42` but that doesn't work because const-prop doesn't support `Operand::Indirect` // and `InterpCx::eval_place()` always forces an allocation which creates the `Indirect`. // Fixing either of those will allow us to const-prop this away. </ins> // EMIT_MIR_FOR_EACH_BIT_WIDTH // EMIT_MIR rustc.main.ConstProp.diff fn main() {

+ // MIR for `main` after ConstProp fn main() -> () { <del> let mut _0: ();                      // return place in scope 0 at $DIR/discriminant.rs:5:11: 5:11 let _1: i32;                         // in scope 0 at $DIR/discriminant.rs:6:9: 6:10 let mut _2: i32;                     // in scope 0 at $DIR/discriminant.rs:6:13: 6:64 let mut _3: std::option::Option<bool>; // in scope 0 at $DIR/discriminant.rs:6:34: 6:44 let mut _4: isize;                   // in scope 0 at $DIR/discriminant.rs:6:21: 6:31 </del> <ins> let mut _0: ();                      // return place in scope 0 at $DIR/discriminant.rs:10:11: 10:11 let _1: i32;                         // in scope 0 at $DIR/discriminant.rs:11:9: 11:10 let mut _2: i32;                     // in scope 0 at $DIR/discriminant.rs:11:13: 11:64 let mut _3: std::option::Option<bool>; // in scope 0 at $DIR/discriminant.rs:11:34: 11:44 let mut _4: isize;                   // in scope 0 at $DIR/discriminant.rs:11:21: 11:31 </ins> scope 1 { <del> debug x => _1;                   // in scope 1 at $DIR/discriminant.rs:6:9: 6:10 </del> <ins> debug x => _1;                   // in scope 1 at $DIR/discriminant.rs:11:9: 11:10 </ins> } bb0: { <del> StorageLive(_1);                 // scope 0 at $DIR/discriminant.rs:6:9: 6:10 StorageLive(_2);                 // scope 0 at $DIR/discriminant.rs:6:13: 6:64 StorageLive(_3);                 // scope 0 at $DIR/discriminant.rs:6:34: 6:44 -         _3 = std::option::Option::<bool>::Some(const true); // scope 0 at $DIR/discriminant.rs:6:34: 6:44 +         _3 = const std::option::Option::<bool>::Some(true); // scope 0 at $DIR/discriminant.rs:6:34: 6:44 </del> <ins> StorageLive(_1);                 // scope 0 at $DIR/discriminant.rs:11:9: 11:10 StorageLive(_2);                 // scope 0 at $DIR/discriminant.rs:11:13: 11:64 StorageLive(_3);                 // scope 0 at $DIR/discriminant.rs:11:34: 11:44 -         _3 = std::option::Option::<bool>::Some(const true); // scope 0 at $DIR/discriminant.rs:11:34: 11:44 +         _3 = const std::option::Option::<bool>::Some(true); // scope 0 at $DIR/discriminant.rs:11:34: 11:44 </ins> // ty::Const -                                          // + ty: bool +                                          // + ty: std::option::Option<bool> // + val: Value(Scalar(0x01)) // mir::Constant <del> -                                          // + span: $DIR/discriminant.rs:6:39: 6:43 </del> <ins> -                                          // + span: $DIR/discriminant.rs:11:39: 11:43 </ins> -                                          // + literal: Const { ty: bool, val: Value(Scalar(0x01)) } <del> -         _4 = discriminant(_3);           // scope 0 at $DIR/discriminant.rs:6:21: 6:31 -         switchInt(move _4) -> [1isize: bb2, otherwise: bb1]; // scope 0 at $DIR/discriminant.rs:6:21: 6:31 +                                          // + span: $DIR/discriminant.rs:6:34: 6:44 </del> <ins> -         _4 = discriminant(_3);           // scope 0 at $DIR/discriminant.rs:11:21: 11:31 -         switchInt(move _4) -> [1isize: bb2, otherwise: bb1]; // scope 0 at $DIR/discriminant.rs:11:21: 11:31 +                                          // + span: $DIR/discriminant.rs:11:34: 11:44 </ins> +                                          // + literal: Const { ty: std::option::Option<bool>, val: Value(Scalar(0x01)) } <del> +         _4 = const 1isize;               // scope 0 at $DIR/discriminant.rs:6:21: 6:31 </del> <ins> +         _4 = const 1isize;               // scope 0 at $DIR/discriminant.rs:11:21: 11:31 </ins> +                                          // ty::Const +                                          // + ty: isize +                                          // + val: Value(Scalar(0x00000001)) +                                          // mir::Constant <del> +                                          // + span: $DIR/discriminant.rs:6:21: 6:31 </del> <ins> +                                          // + span: $DIR/discriminant.rs:11:21: 11:31 </ins> +                                          // + literal: Const { ty: isize, val: Value(Scalar(0x00000001)) } <del> +         switchInt(const 1isize) -> [1isize: bb2, otherwise: bb1]; // scope 0 at $DIR/discriminant.rs:6:21: 6:31 </del> <ins> +         switchInt(const 1isize) -> [1isize: bb2, otherwise: bb1]; // scope 0 at $DIR/discriminant.rs:11:21: 11:31 </ins> +                                          // ty::Const +                                          // + ty: isize +                                          // + val: Value(Scalar(0x00000001)) +                                          // mir::Constant <del> +                                          // + span: $DIR/discriminant.rs:6:21: 6:31 </del> <ins> +                                          // + span: $DIR/discriminant.rs:11:21: 11:31 </ins> +                                          // + literal: Const { ty: isize, val: Value(Scalar(0x00000001)) } } bb1: { <del> _2 = const 10i32;                // scope 0 at $DIR/discriminant.rs:6:59: 6:61 </del> <ins> _2 = const 10i32;                // scope 0 at $DIR/discriminant.rs:11:59: 11:61 </ins> // ty::Const // + ty: i32 // + val: Value(Scalar(0x0000000a)) // mir::Constant <del> // + span: $DIR/discriminant.rs:6:59: 6:61 </del> <ins> // + span: $DIR/discriminant.rs:11:59: 11:61 </ins> // + literal: Const { ty: i32, val: Value(Scalar(0x0000000a)) } <del> goto -> bb4;                     // scope 0 at $DIR/discriminant.rs:6:13: 6:64 </del> <ins> goto -> bb4;                     // scope 0 at $DIR/discriminant.rs:11:13: 11:64 </ins> } bb2: { <del> -         switchInt(((_3 as Some).0: bool)) -> [false: bb1, otherwise: bb3]; // scope 0 at $DIR/discriminant.rs:6:26: 6:30 +         switchInt(const true) -> [false: bb1, otherwise: bb3]; // scope 0 at $DIR/discriminant.rs:6:26: 6:30 +                                          // ty::Const +                                          // + ty: bool +                                          // + val: Value(Scalar(0x01)) +                                          // mir::Constant +                                          // + span: $DIR/discriminant.rs:6:26: 6:30 +                                          // + literal: Const { ty: bool, val: Value(Scalar(0x01)) } </del> <ins> switchInt(((_3 as Some).0: bool)) -> [false: bb1, otherwise: bb3]; // scope 0 at $DIR/discriminant.rs:11:26: 11:30 </ins> } bb3: { <del> _2 = const 42i32;                // scope 0 at $DIR/discriminant.rs:6:47: 6:49 </del> <ins> _2 = const 42i32;                // scope 0 at $DIR/discriminant.rs:11:47: 11:49 </ins> // ty::Const // + ty: i32 // + val: Value(Scalar(0x0000002a)) // mir::Constant <del> // + span: $DIR/discriminant.rs:6:47: 6:49 </del> <ins> // + span: $DIR/discriminant.rs:11:47: 11:49 </ins> // + literal: Const { ty: i32, val: Value(Scalar(0x0000002a)) } <del> goto -> bb4;                     // scope 0 at $DIR/discriminant.rs:6:13: 6:64 </del> <ins> goto -> bb4;                     // scope 0 at $DIR/discriminant.rs:11:13: 11:64 </ins> } bb4: { <del> _1 = Add(move _2, const 0i32);   // scope 0 at $DIR/discriminant.rs:6:13: 6:68 </del> <ins> _1 = Add(move _2, const 0i32);   // scope 0 at $DIR/discriminant.rs:11:13: 11:68 </ins> // ty::Const // + ty: i32 // + val: Value(Scalar(0x00000000)) // mir::Constant <del> // + span: $DIR/discriminant.rs:6:67: 6:68 </del> <ins> // + span: $DIR/discriminant.rs:11:67: 11:68 </ins> // + literal: Const { ty: i32, val: Value(Scalar(0x00000000)) } <del> StorageDead(_2);                 // scope 0 at $DIR/discriminant.rs:6:67: 6:68 StorageDead(_3);                 // scope 0 at $DIR/discriminant.rs:6:68: 6:69 _0 = const ();                   // scope 0 at $DIR/discriminant.rs:5:11: 7:2 </del> <ins> StorageDead(_2);                 // scope 0 at $DIR/discriminant.rs:11:67: 11:68 StorageDead(_3);                 // scope 0 at $DIR/discriminant.rs:11:68: 11:69 _0 = const ();                   // scope 0 at $DIR/discriminant.rs:10:11: 12:2 </ins> // ty::Const // + ty: () // + val: Value(Scalar(<ZST>)) // mir::Constant <del> // + span: $DIR/discriminant.rs:5:11: 7:2 </del> <ins> // + span: $DIR/discriminant.rs:10:11: 12:2 </ins> // + literal: Const { ty: (), val: Value(Scalar(<ZST>)) } <del> StorageDead(_1);                 // scope 0 at $DIR/discriminant.rs:7:1: 7:2 return;                          // scope 0 at $DIR/discriminant.rs:7:2: 7:2 </del> <ins> StorageDead(_1);                 // scope 0 at $DIR/discriminant.rs:12:1: 12:2 return;                          // scope 0 at $DIR/discriminant.rs:12:2: 12:2 </ins> } }

+ // MIR for `main` after ConstProp fn main() -> () { <del> let mut _0: ();                      // return place in scope 0 at $DIR/discriminant.rs:5:11: 5:11 let _1: i32;                         // in scope 0 at $DIR/discriminant.rs:6:9: 6:10 let mut _2: i32;                     // in scope 0 at $DIR/discriminant.rs:6:13: 6:64 let mut _3: std::option::Option<bool>; // in scope 0 at $DIR/discriminant.rs:6:34: 6:44 let mut _4: isize;                   // in scope 0 at $DIR/discriminant.rs:6:21: 6:31 </del> <ins> let mut _0: ();                      // return place in scope 0 at $DIR/discriminant.rs:10:11: 10:11 let _1: i32;                         // in scope 0 at $DIR/discriminant.rs:11:9: 11:10 let mut _2: i32;                     // in scope 0 at $DIR/discriminant.rs:11:13: 11:64 let mut _3: std::option::Option<bool>; // in scope 0 at $DIR/discriminant.rs:11:34: 11:44 let mut _4: isize;                   // in scope 0 at $DIR/discriminant.rs:11:21: 11:31 </ins> scope 1 { <del> debug x => _1;                   // in scope 1 at $DIR/discriminant.rs:6:9: 6:10 </del> <ins> debug x => _1;                   // in scope 1 at $DIR/discriminant.rs:11:9: 11:10 </ins> } bb0: { <del> StorageLive(_1);                 // scope 0 at $DIR/discriminant.rs:6:9: 6:10 StorageLive(_2);                 // scope 0 at $DIR/discriminant.rs:6:13: 6:64 StorageLive(_3);                 // scope 0 at $DIR/discriminant.rs:6:34: 6:44 -         _3 = std::option::Option::<bool>::Some(const true); // scope 0 at $DIR/discriminant.rs:6:34: 6:44 +         _3 = const std::option::Option::<bool>::Some(true); // scope 0 at $DIR/discriminant.rs:6:34: 6:44 </del> <ins> StorageLive(_1);                 // scope 0 at $DIR/discriminant.rs:11:9: 11:10 StorageLive(_2);                 // scope 0 at $DIR/discriminant.rs:11:13: 11:64 StorageLive(_3);                 // scope 0 at $DIR/discriminant.rs:11:34: 11:44 -         _3 = std::option::Option::<bool>::Some(const true); // scope 0 at $DIR/discriminant.rs:11:34: 11:44 +         _3 = const std::option::Option::<bool>::Some(true); // scope 0 at $DIR/discriminant.rs:11:34: 11:44 </ins> // ty::Const -                                          // + ty: bool +                                          // + ty: std::option::Option<bool> // + val: Value(Scalar(0x01)) // mir::Constant <del> -                                          // + span: $DIR/discriminant.rs:6:39: 6:43 </del> <ins> -                                          // + span: $DIR/discriminant.rs:11:39: 11:43 </ins> -                                          // + literal: Const { ty: bool, val: Value(Scalar(0x01)) } <del> -         _4 = discriminant(_3);           // scope 0 at $DIR/discriminant.rs:6:21: 6:31 -         switchInt(move _4) -> [1isize: bb2, otherwise: bb1]; // scope 0 at $DIR/discriminant.rs:6:21: 6:31 +                                          // + span: $DIR/discriminant.rs:6:34: 6:44 </del> <ins> -         _4 = discriminant(_3);           // scope 0 at $DIR/discriminant.rs:11:21: 11:31 -         switchInt(move _4) -> [1isize: bb2, otherwise: bb1]; // scope 0 at $DIR/discriminant.rs:11:21: 11:31 +                                          // + span: $DIR/discriminant.rs:11:34: 11:44 </ins> +                                          // + literal: Const { ty: std::option::Option<bool>, val: Value(Scalar(0x01)) } <del> +         _4 = const 1isize;               // scope 0 at $DIR/discriminant.rs:6:21: 6:31 </del> <ins> +         _4 = const 1isize;               // scope 0 at $DIR/discriminant.rs:11:21: 11:31 </ins> +                                          // ty::Const +                                          // + ty: isize +                                          // + val: Value(Scalar(0x0000000000000001)) +                                          // mir::Constant <del> +                                          // + span: $DIR/discriminant.rs:6:21: 6:31 </del> <ins> +                                          // + span: $DIR/discriminant.rs:11:21: 11:31 </ins> +                                          // + literal: Const { ty: isize, val: Value(Scalar(0x0000000000000001)) } <del> +         switchInt(const 1isize) -> [1isize: bb2, otherwise: bb1]; // scope 0 at $DIR/discriminant.rs:6:21: 6:31 </del> <ins> +         switchInt(const 1isize) -> [1isize: bb2, otherwise: bb1]; // scope 0 at $DIR/discriminant.rs:11:21: 11:31 </ins> +                                          // ty::Const +                                          // + ty: isize +                                          // + val: Value(Scalar(0x0000000000000001)) +                                          // mir::Constant <del> +                                          // + span: $DIR/discriminant.rs:6:21: 6:31 </del> <ins> +                                          // + span: $DIR/discriminant.rs:11:21: 11:31 </ins> +                                          // + literal: Const { ty: isize, val: Value(Scalar(0x0000000000000001)) } } bb1: { <del> _2 = const 10i32;                // scope 0 at $DIR/discriminant.rs:6:59: 6:61 </del> <ins> _2 = const 10i32;                // scope 0 at $DIR/discriminant.rs:11:59: 11:61 </ins> // ty::Const // + ty: i32 // + val: Value(Scalar(0x0000000a)) // mir::Constant <del> // + span: $DIR/discriminant.rs:6:59: 6:61 </del> <ins> // + span: $DIR/discriminant.rs:11:59: 11:61 </ins> // + literal: Const { ty: i32, val: Value(Scalar(0x0000000a)) } <del> goto -> bb4;                     // scope 0 at $DIR/discriminant.rs:6:13: 6:64 </del> <ins> goto -> bb4;                     // scope 0 at $DIR/discriminant.rs:11:13: 11:64 </ins> } bb2: { <del> -         switchInt(((_3 as Some).0: bool)) -> [false: bb1, otherwise: bb3]; // scope 0 at $DIR/discriminant.rs:6:26: 6:30 +         switchInt(const true) -> [false: bb1, otherwise: bb3]; // scope 0 at $DIR/discriminant.rs:6:26: 6:30 +                                          // ty::Const +                                          // + ty: bool +                                          // + val: Value(Scalar(0x01)) +                                          // mir::Constant +                                          // + span: $DIR/discriminant.rs:6:26: 6:30 +                                          // + literal: Const { ty: bool, val: Value(Scalar(0x01)) } </del> <ins> switchInt(((_3 as Some).0: bool)) -> [false: bb1, otherwise: bb3]; // scope 0 at $DIR/discriminant.rs:11:26: 11:30 </ins> } bb3: { <del> _2 = const 42i32;                // scope 0 at $DIR/discriminant.rs:6:47: 6:49 </del> <ins> _2 = const 42i32;                // scope 0 at $DIR/discriminant.rs:11:47: 11:49 </ins> // ty::Const // + ty: i32 // + val: Value(Scalar(0x0000002a)) // mir::Constant <del> // + span: $DIR/discriminant.rs:6:47: 6:49 </del> <ins> // + span: $DIR/discriminant.rs:11:47: 11:49 </ins> // + literal: Const { ty: i32, val: Value(Scalar(0x0000002a)) } <del> goto -> bb4;                     // scope 0 at $DIR/discriminant.rs:6:13: 6:64 </del> <ins> goto -> bb4;                     // scope 0 at $DIR/discriminant.rs:11:13: 11:64 </ins> } bb4: { <del> _1 = Add(move _2, const 0i32);   // scope 0 at $DIR/discriminant.rs:6:13: 6:68 </del> <ins> _1 = Add(move _2, const 0i32);   // scope 0 at $DIR/discriminant.rs:11:13: 11:68 </ins> // ty::Const // + ty: i32 // + val: Value(Scalar(0x00000000)) // mir::Constant <del> // + span: $DIR/discriminant.rs:6:67: 6:68 </del> <ins> // + span: $DIR/discriminant.rs:11:67: 11:68 </ins> // + literal: Const { ty: i32, val: Value(Scalar(0x00000000)) } <del> StorageDead(_2);                 // scope 0 at $DIR/discriminant.rs:6:67: 6:68 StorageDead(_3);                 // scope 0 at $DIR/discriminant.rs:6:68: 6:69 _0 = const ();                   // scope 0 at $DIR/discriminant.rs:5:11: 7:2 </del> <ins> StorageDead(_2);                 // scope 0 at $DIR/discriminant.rs:11:67: 11:68 StorageDead(_3);                 // scope 0 at $DIR/discriminant.rs:11:68: 11:69 _0 = const ();                   // scope 0 at $DIR/discriminant.rs:10:11: 12:2 </ins> // ty::Const // + ty: () // + val: Value(Scalar(<ZST>)) // mir::Constant <del> // + span: $DIR/discriminant.rs:5:11: 7:2 </del> <ins> // + span: $DIR/discriminant.rs:10:11: 12:2 </ins> // + literal: Const { ty: (), val: Value(Scalar(<ZST>)) } <del> StorageDead(_1);                 // scope 0 at $DIR/discriminant.rs:7:1: 7:2 return;                          // scope 0 at $DIR/discriminant.rs:7:2: 7:2 </del> <ins> StorageDead(_1);                 // scope 0 at $DIR/discriminant.rs:12:1: 12:2 return;                          // scope 0 at $DIR/discriminant.rs:12:2: 12:2 </ins> } }