Skip to content

Commit 8509dbb

Browse files
committed
validation: allow undef integers and raw pointers, as a crude work-around
1 parent 2ea6663 commit 8509dbb

File tree

1 file changed

+5
-12
lines changed

1 file changed

+5
-12
lines changed

src/librustc_mir/interpret/validation.rs

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -493,26 +493,19 @@ impl<'a, 'tcx, M: Machine<'tcx>> EvalContext<'a, 'tcx, M> {
493493
match query.ty.sty {
494494
TyInt(_) | TyUint(_) | TyRawPtr(_) => {
495495
if mode.acquiring() {
496-
// Make sure there is no undef
496+
// Make sure we can read this.
497497
let val = self.read_lvalue(query.lval.1)?;
498-
// This is essentially value_to_primval with support for fat pointers
499-
let has_undef = match self.follow_by_ref_value(val, query.ty)? {
500-
Value::ByRef { .. } => bug!("follow_by_ref_value can't result in `ByRef`"),
501-
Value::ByVal(primval) => primval.is_undef(),
502-
Value::ByValPair(primval1, primval2) =>
503-
primval1.is_undef() || primval2.is_undef()
504-
};
505-
if has_undef {
506-
return err!(ReadUndefBytes);
507-
}
498+
self.follow_by_ref_value(val, query.ty)?;
499+
// FIXME: It would be great to rule out Undef here, but that doesn't actually work.
500+
// Passing around undef data is a thing that e.g. Vec::extend_with does.
508501
}
509502
Ok(())
510503
}
511504
TyBool | TyFloat(_) | TyChar => {
512505
if mode.acquiring() {
513506
let val = self.read_lvalue(query.lval.1)?;
514507
let val = self.value_to_primval(ValTy { value: val, ty: query.ty })?;
515-
let _val = val.to_bytes()?;
508+
val.to_bytes()?;
516509
// TODO: Check if these are valid bool/float/codepoint/UTF-8
517510
}
518511
Ok(())

0 commit comments

Comments
 (0)