@@ -207,7 +207,7 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M>
207
207
bug ! ( "Unexpected unsized type tail: {:?}" , tail) ,
208
208
}
209
209
}
210
- // for safe ptrs, recursively check
210
+ // for safe ptrs, also check the ptr values itself
211
211
if !ty. is_unsafe_ptr ( ) {
212
212
// Make sure this is non-NULL and aligned
213
213
let ( size, align) = self . size_and_align_of ( place. extra , place. layout ) ?;
@@ -556,9 +556,13 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M>
556
556
match layout. ty . sty {
557
557
// generators and closures.
558
558
ty:: Closure ( def_id, _) | ty:: Generator ( def_id, _, _) => {
559
- let node_id = self . tcx . hir . as_local_node_id ( def_id) . unwrap ( ) ;
560
- let freevar = self . tcx . with_freevars ( node_id, |fv| fv[ field] ) ;
561
- PathElem :: ClosureVar ( self . tcx . hir . name ( freevar. var_id ( ) ) )
559
+ if let Some ( node_id) = self . tcx . hir . as_local_node_id ( def_id) {
560
+ let freevar = self . tcx . with_freevars ( node_id, |fv| fv[ field] ) ;
561
+ PathElem :: ClosureVar ( self . tcx . hir . name ( freevar. var_id ( ) ) )
562
+ } else {
563
+ // The closure is not local, so we cannot get the name
564
+ PathElem :: ClosureVar ( Symbol :: intern ( & field. to_string ( ) ) )
565
+ }
562
566
}
563
567
564
568
// tuples
0 commit comments