@@ -443,13 +443,16 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
443443 ) -> bool /* did we suggest to call a function because of missing parenthesis? */ {
444444 err. span_label ( span, ty. to_string ( ) ) ;
445445 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+ } ;
446451 if self . tcx . has_typeck_tables ( def_id) == false {
447452 return false ;
448453 }
449- let source_map = self . tcx . sess . source_map ( ) ;
450- let hir_id = & self . tcx . hir ( ) . as_local_hir_id ( def_id) . unwrap ( ) ;
451454 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) {
453456 Some ( f) => f. clone ( ) ,
454457 None => {
455458 bug ! ( "No fn-sig entry for def_id={:?}" , def_id) ;
@@ -458,11 +461,14 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
458461 } ;
459462
460463 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+ } ;
461468 if self . tcx . has_typeck_tables ( def_id) == false {
462469 return false ;
463470 }
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) {
466472 Some ( f) => f. clone ( ) . output ( ) ,
467473 None => {
468474 bug ! ( "No fn-sig entry for def_id={:?}" , def_id) ;
0 commit comments