@@ -8,7 +8,7 @@ use crate::hir::def_id::DefId;
8
8
use crate :: ty:: subst:: { GenericArg , GenericArgKind , SubstsRef } ;
9
9
use crate :: ty:: { self , Ty , TyCtxt , TypeFoldable } ;
10
10
use 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} ;
12
12
use std:: rc:: Rc ;
13
13
use std:: iter;
14
14
use rustc_target:: spec:: abi;
@@ -577,16 +577,8 @@ pub fn super_relate_consts<R: TypeRelation<'tcx>>(
577
577
Ok ( ConstValue :: Scalar ( a_val) )
578
578
} else if let ty:: FnPtr ( _) = a. ty . kind {
579
579
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 ) ;
590
582
if a_instance == b_instance {
591
583
Ok ( ConstValue :: Scalar ( a_val) )
592
584
} else {
0 commit comments