@@ -1774,15 +1774,15 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
17741774 // that highlight errors inline.
17751775 let mut sp = blk. span ;
17761776 let mut fn_span = None ;
1777- if let Some ( ( decl, ident ) ) = self . get_parent_fn_decl ( blk. hir_id ) {
1777+ if let Some ( ( fn_def_id , decl, _ ) ) = self . get_fn_decl ( blk. hir_id ) {
17781778 let ret_sp = decl. output . span ( ) ;
17791779 if let Some ( block_sp) = self . parent_item_span ( blk. hir_id ) {
17801780 // HACK: on some cases (`ui/liveness/liveness-issue-2163.rs`) the
17811781 // output would otherwise be incorrect and even misleading. Make sure
17821782 // the span we're aiming at correspond to a `fn` body.
17831783 if block_sp == blk. span {
17841784 sp = ret_sp;
1785- fn_span = Some ( ident . span ) ;
1785+ fn_span = self . tcx . def_ident_span ( fn_def_id ) ;
17861786 }
17871787 }
17881788 }
@@ -1897,15 +1897,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
18971897 None
18981898 }
18991899
1900- /// Given a function block's `HirId`, returns its `FnDecl` if it exists, or `None` otherwise.
1901- pub ( crate ) fn get_parent_fn_decl (
1902- & self ,
1903- blk_id : HirId ,
1904- ) -> Option < ( & ' tcx hir:: FnDecl < ' tcx > , Ident ) > {
1905- let parent = self . tcx . hir_node_by_def_id ( self . tcx . hir ( ) . get_parent_item ( blk_id) . def_id ) ;
1906- self . get_node_fn_decl ( parent) . map ( |( _, fn_decl, ident, _) | ( fn_decl, ident) )
1907- }
1908-
19091900 /// If `expr` is a `match` expression that has only one non-`!` arm, use that arm's tail
19101901 /// expression's `Span`, otherwise return `expr.span`. This is done to give better errors
19111902 /// when given code like the following:
0 commit comments