@@ -6,14 +6,12 @@ use rustc::hir;
6
6
use rustc:: ty:: layout:: { self , TyLayout , LayoutOf , VariantIdx } ;
7
7
use rustc:: ty;
8
8
use rustc_data_structures:: fx:: FxHashSet ;
9
- use rustc:: mir:: interpret:: {
10
- GlobalAlloc , InterpResult , InterpError ,
11
- } ;
12
9
13
10
use std:: hash:: Hash ;
14
11
15
12
use super :: {
16
- OpTy , Machine , InterpCx , ValueVisitor , MPlaceTy ,
13
+ GlobalAlloc , InterpResult , InterpError ,
14
+ OpTy , Machine , InterpCx , ValueVisitor , MPlaceTy , AllocCheck ,
17
15
} ;
18
16
19
17
macro_rules! validation_failure {
@@ -505,19 +503,20 @@ impl<'rt, 'mir, 'tcx, M: Machine<'mir, 'tcx>> ValueVisitor<'mir, 'tcx, M>
505
503
// Only NULL is the niche. So make sure the ptr is NOT NULL.
506
504
if self . ecx . memory . ptr_may_be_null ( ptr) {
507
505
// These conditions are just here to improve the diagnostics so we can
508
- // differentiate between null pointers and dangling pointers
506
+ // differentiate between null pointers and dangling pointers.
509
507
if self . ref_tracking_for_consts . is_some ( ) &&
510
- self . ecx . memory . get ( ptr. alloc_id ) . is_err ( ) &&
511
- self . ecx . memory . get_fn ( ptr. into ( ) ) . is_err ( ) {
508
+ self . ecx . memory . get_size_and_align ( ptr. alloc_id , AllocCheck :: Live )
509
+ . is_err ( )
510
+ {
512
511
return validation_failure ! (
513
- "encountered dangling pointer" , self . path
512
+ "a dangling pointer" , self . path
514
513
) ;
515
514
}
516
515
return validation_failure ! ( "a potentially NULL pointer" , self . path) ;
517
516
}
518
517
return Ok ( ( ) ) ;
519
518
} else {
520
- // Conservatively, we reject, because the pointer *could* have this
519
+ // Conservatively, we reject, because the pointer *could* have a bad
521
520
// value.
522
521
return validation_failure ! (
523
522
"a pointer" ,
0 commit comments