@@ -492,12 +492,22 @@ impl<'a, 'tcx, M: Machine<'tcx>> EvalContext<'a, 'tcx, M> {
492
492
let res = do catch {
493
493
match query. ty . sty {
494
494
TyInt ( _) | TyUint ( _) | TyRawPtr ( _) => {
495
- // TODO: Make sure these are not undef.
496
- // We could do a bounds-check and other sanity checks on the lvalue, but it would be a bug in miri for this to ever fail.
495
+ if mode. acquiring ( ) {
496
+ // Make sure we can read this.
497
+ let val = self . read_lvalue ( query. lval . 1 ) ?;
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.
501
+ }
497
502
Ok ( ( ) )
498
503
}
499
- TyBool | TyFloat ( _) | TyChar | TyStr => {
500
- // TODO: Check if these are valid bool/float/codepoint/UTF-8, respectively (and in particular, not undef).
504
+ TyBool | TyFloat ( _) | TyChar => {
505
+ if mode. acquiring ( ) {
506
+ let val = self . read_lvalue ( query. lval . 1 ) ?;
507
+ let val = self . value_to_primval ( ValTy { value : val, ty : query. ty } ) ?;
508
+ val. to_bytes ( ) ?;
509
+ // TODO: Check if these are valid bool/float/codepoint/UTF-8
510
+ }
501
511
Ok ( ( ) )
502
512
}
503
513
TyNever => err!( ValidationFailure ( format ! ( "The empty type is never valid." ) ) ) ,
@@ -542,6 +552,10 @@ impl<'a, 'tcx, M: Machine<'tcx>> EvalContext<'a, 'tcx, M> {
542
552
}
543
553
544
554
// Compound types
555
+ TyStr => {
556
+ // TODO: Validate strings
557
+ Ok ( ( ) )
558
+ }
545
559
TySlice ( elem_ty) => {
546
560
let len = match query. lval . 1 {
547
561
Lvalue :: Ptr { extra : LvalueExtra :: Length ( len) , .. } => len,
0 commit comments