You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: compiler/rustc_const_eval/src/interpret/projection.rs
+18
Original file line number
Diff line number
Diff line change
@@ -208,6 +208,24 @@ where
208
208
if layout.abi.is_uninhabited(){
209
209
// `read_discriminant` should have excluded uninhabited variants... but ConstProp calls
210
210
// 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.
211
229
throw_inval!(ConstPropNonsense)
212
230
}
213
231
// This cannot be `transmute` as variants *can* have a smaller size than the entire enum.
0 commit comments