@@ -443,13 +443,16 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
443
443
) -> bool /* did we suggest to call a function because of missing parenthesis? */ {
444
444
err. span_label ( span, ty. to_string ( ) ) ;
445
445
if let FnDef ( def_id, _) = ty. sty {
446
+ let source_map = self . tcx . sess . source_map ( ) ;
447
+ let hir_id = match self . tcx . hir ( ) . as_local_hir_id ( def_id) {
448
+ Some ( hir_id) => hir_id,
449
+ None => return false ,
450
+ } ;
446
451
if self . tcx . has_typeck_tables ( def_id) == false {
447
452
return false ;
448
453
}
449
- let source_map = self . tcx . sess . source_map ( ) ;
450
- let hir_id = & self . tcx . hir ( ) . as_local_hir_id ( def_id) . unwrap ( ) ;
451
454
let fn_sig = {
452
- match self . tcx . typeck_tables_of ( def_id) . liberated_fn_sigs ( ) . get ( * hir_id) {
455
+ match self . tcx . typeck_tables_of ( def_id) . liberated_fn_sigs ( ) . get ( hir_id) {
453
456
Some ( f) => f. clone ( ) ,
454
457
None => {
455
458
bug ! ( "No fn-sig entry for def_id={:?}" , def_id) ;
@@ -458,11 +461,14 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
458
461
} ;
459
462
460
463
let other_ty = if let FnDef ( def_id, _) = other_ty. sty {
464
+ let hir_id = match self . tcx . hir ( ) . as_local_hir_id ( def_id) {
465
+ Some ( hir_id) => hir_id,
466
+ None => return false ,
467
+ } ;
461
468
if self . tcx . has_typeck_tables ( def_id) == false {
462
469
return false ;
463
470
}
464
- let hir_id = & self . tcx . hir ( ) . as_local_hir_id ( def_id) . unwrap ( ) ;
465
- match self . tcx . typeck_tables_of ( def_id) . liberated_fn_sigs ( ) . get ( * hir_id) {
471
+ match self . tcx . typeck_tables_of ( def_id) . liberated_fn_sigs ( ) . get ( hir_id) {
466
472
Some ( f) => f. clone ( ) . output ( ) ,
467
473
None => {
468
474
bug ! ( "No fn-sig entry for def_id={:?}" , def_id) ;
0 commit comments