@@ -8,7 +8,7 @@ use crate::hir::def_id::DefId;
88use crate :: ty:: subst:: { GenericArg , GenericArgKind , SubstsRef } ;
99use crate :: ty:: { self , Ty , TyCtxt , TypeFoldable } ;
1010use crate :: ty:: error:: { ExpectedFound , TypeError } ;
11- use crate :: mir:: interpret:: { ConstValue , get_slice_bytes, Scalar , GlobalAlloc } ;
11+ use crate :: mir:: interpret:: { ConstValue , get_slice_bytes} ;
1212use std:: rc:: Rc ;
1313use std:: iter;
1414use rustc_target:: spec:: abi;
@@ -577,16 +577,8 @@ pub fn super_relate_consts<R: TypeRelation<'tcx>>(
577577 Ok ( ConstValue :: Scalar ( a_val) )
578578 } else if let ty:: FnPtr ( _) = a. ty . kind {
579579 let alloc_map = tcx. alloc_map . lock ( ) ;
580- let get_fn_instance = |val : Scalar | {
581- let ptr = val. to_ptr ( ) . unwrap ( ) ;
582- if let Some ( GlobalAlloc :: Function ( instance) ) = alloc_map. get ( ptr. alloc_id ) {
583- instance
584- } else {
585- bug ! ( "Allocation for FnPtr isn't a function" ) ;
586- }
587- } ;
588- let a_instance = get_fn_instance ( a_val) ;
589- let b_instance = get_fn_instance ( b_val) ;
580+ let a_instance = alloc_map. unwrap_fn ( a_val. to_ptr ( ) . unwrap ( ) . alloc_id ) ;
581+ let b_instance = alloc_map. unwrap_fn ( b_val. to_ptr ( ) . unwrap ( ) . alloc_id ) ;
590582 if a_instance == b_instance {
591583 Ok ( ConstValue :: Scalar ( a_val) )
592584 } else {
0 commit comments