Skip to content

Commit

Permalink
Rollup merge of rust-lang#91088 - RalfJung:revert, r=oli-obk
Browse files Browse the repository at this point in the history
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`
  • Loading branch information
matthiaskrgr authored Nov 20, 2021
2 parents ec2f087 + 70d418c commit 83c83d4
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 12 deletions.
6 changes: 0 additions & 6 deletions compiler/rustc_const_eval/src/interpret/intrinsics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -265,12 +265,6 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
}
sym::discriminant_value => {
let place = self.deref_operand(&args[0])?;
if M::enforce_validity(self) {
// This is 'using' the value, so make sure the validity invariant is satisfied.
// (Also see https://github.com/rust-lang/rust/pull/89764.)
self.validate_operand(&place.into())?;
}

let discr_val = self.read_discriminant(&place.into())?.0;
self.write_scalar(discr_val, dest)?;
}
Expand Down
6 changes: 0 additions & 6 deletions compiler/rustc_const_eval/src/interpret/step.rs
Original file line number Diff line number Diff line change
Expand Up @@ -304,12 +304,6 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {

Discriminant(place) => {
let op = self.eval_place_to_op(place, None)?;
if M::enforce_validity(self) {
// This is 'using' the value, so make sure the validity invariant is satisfied.
// (Also see https://github.com/rust-lang/rust/pull/89764.)
self.validate_operand(&op)?;
}

let discr_val = self.read_discriminant(&op)?.0;
self.write_scalar(discr_val, &dest)?;
}
Expand Down

0 comments on commit 83c83d4

Please sign in to comment.