File tree Expand file tree Collapse file tree 1 file changed +18
-0
lines changed
compiler/rustc_const_eval/src/interpret Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -208,6 +208,24 @@ where
208208 if layout. abi . is_uninhabited ( ) {
209209 // `read_discriminant` should have excluded uninhabited variants... but ConstProp calls
210210 // us on dead code.
211+ // In the future we might want to allow this to permit code like this:
212+ // (this is a Rust/MIR pseudocode mix)
213+ // ```
214+ // enum Option2 {
215+ // Some(i32, !),
216+ // None,
217+ // }
218+ //
219+ // fn panic() -> ! { panic!() }
220+ //
221+ // let x: Option2;
222+ // x.Some.0 = 42;
223+ // x.Some.1 = panic();
224+ // SetDiscriminant(x, Some);
225+ // ```
226+ // However, for now we don't generate such MIR, and this check here *has* found real
227+ // bugs (see https://github.com/rust-lang/rust/issues/115145), so we will keep rejecting
228+ // it.
211229 throw_inval ! ( ConstPropNonsense )
212230 }
213231 // This cannot be `transmute` as variants *can* have a smaller size than the entire enum.
You can’t perform that action at this time.
0 commit comments