@@ -6,14 +6,12 @@ use rustc::hir;
66use rustc:: ty:: layout:: { self , TyLayout , LayoutOf , VariantIdx } ;
77use rustc:: ty;
88use rustc_data_structures:: fx:: FxHashSet ;
9- use rustc:: mir:: interpret:: {
10- GlobalAlloc , InterpResult , InterpError ,
11- } ;
129
1310use std:: hash:: Hash ;
1411
1512use super :: {
16- OpTy , Machine , InterpCx , ValueVisitor , MPlaceTy ,
13+ GlobalAlloc , InterpResult , InterpError ,
14+ OpTy , Machine , InterpCx , ValueVisitor , MPlaceTy , AllocCheck ,
1715} ;
1816
1917macro_rules! validation_failure {
@@ -505,19 +503,20 @@ impl<'rt, 'mir, 'tcx, M: Machine<'mir, 'tcx>> ValueVisitor<'mir, 'tcx, M>
505503 // Only NULL is the niche. So make sure the ptr is NOT NULL.
506504 if self . ecx . memory . ptr_may_be_null ( ptr) {
507505 // 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.
509507 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+ {
512511 return validation_failure ! (
513- "encountered dangling pointer" , self . path
512+ "a dangling pointer" , self . path
514513 ) ;
515514 }
516515 return validation_failure ! ( "a potentially NULL pointer" , self . path) ;
517516 }
518517 return Ok ( ( ) ) ;
519518 } else {
520- // Conservatively, we reject, because the pointer *could* have this
519+ // Conservatively, we reject, because the pointer *could* have a bad
521520 // value.
522521 return validation_failure ! (
523522 "a pointer" ,
0 commit comments