require full validity when determining the discriminant of a value
This commit is contained in:
parent
1b12d01903
commit
498ebc46ba
2 changed files with 12 additions and 0 deletions
|
@ -265,6 +265,12 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
|
||||||
}
|
}
|
||||||
sym::discriminant_value => {
|
sym::discriminant_value => {
|
||||||
let place = self.deref_operand(&args[0])?;
|
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;
|
let discr_val = self.read_discriminant(&place.into())?.0;
|
||||||
self.write_scalar(discr_val, dest)?;
|
self.write_scalar(discr_val, dest)?;
|
||||||
}
|
}
|
||||||
|
|
|
@ -304,6 +304,12 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
|
||||||
|
|
||||||
Discriminant(place) => {
|
Discriminant(place) => {
|
||||||
let op = self.eval_place_to_op(place, None)?;
|
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;
|
let discr_val = self.read_discriminant(&op)?.0;
|
||||||
self.write_scalar(discr_val, &dest)?;
|
self.write_scalar(discr_val, &dest)?;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue