Skip to content

Commit 83c83d4

Browse files
authored
Rollup merge of rust-lang#91088 - RalfJung:revert, r=oli-obk
Revert "require full validity when determining the discriminant of a value" This reverts commit 0a2b7d7, reversing changes made to 47c1bd1. This caused several unforeseen problems: - rust-lang#91029 - rust-lang#89764 (comment) So I think it's best to revert for now while we keep discussing the MIR semantics of getting a discriminant. r? `@oli-obk`
2 parents ec2f087 + 70d418c commit 83c83d4

File tree

2 files changed

+0
-12
lines changed

2 files changed

+0
-12
lines changed

compiler/rustc_const_eval/src/interpret/intrinsics.rs

-6
Original file line numberDiff line numberDiff line change
@@ -265,12 +265,6 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
265265
}
266266
sym::discriminant_value => {
267267
let place = self.deref_operand(&args[0])?;
268-
if M::enforce_validity(self) {
269-
// This is 'using' the value, so make sure the validity invariant is satisfied.
270-
// (Also see https://github.com/rust-lang/rust/pull/89764.)
271-
self.validate_operand(&place.into())?;
272-
}
273-
274268
let discr_val = self.read_discriminant(&place.into())?.0;
275269
self.write_scalar(discr_val, dest)?;
276270
}

compiler/rustc_const_eval/src/interpret/step.rs

-6
Original file line numberDiff line numberDiff line change
@@ -304,12 +304,6 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
304304

305305
Discriminant(place) => {
306306
let op = self.eval_place_to_op(place, None)?;
307-
if M::enforce_validity(self) {
308-
// This is 'using' the value, so make sure the validity invariant is satisfied.
309-
// (Also see https://github.com/rust-lang/rust/pull/89764.)
310-
self.validate_operand(&op)?;
311-
}
312-
313307
let discr_val = self.read_discriminant(&op)?.0;
314308
self.write_scalar(discr_val, &dest)?;
315309
}

0 commit comments

Comments
 (0)