@@ -207,7 +207,7 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M>
207207 bug ! ( "Unexpected unsized type tail: {:?}" , tail) ,
208208 }
209209 }
210- // for safe ptrs, recursively check
210+ // for safe ptrs, also check the ptr values itself
211211 if !ty. is_unsafe_ptr ( ) {
212212 // Make sure this is non-NULL and aligned
213213 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>
556556 match layout. ty . sty {
557557 // generators and closures.
558558 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+ }
562566 }
563567
564568 // tuples
0 commit comments