@@ -1774,15 +1774,15 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
1774
1774
// that highlight errors inline.
1775
1775
let mut sp = blk. span ;
1776
1776
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 ) {
1778
1778
let ret_sp = decl. output . span ( ) ;
1779
1779
if let Some ( block_sp) = self . parent_item_span ( blk. hir_id ) {
1780
1780
// HACK: on some cases (`ui/liveness/liveness-issue-2163.rs`) the
1781
1781
// output would otherwise be incorrect and even misleading. Make sure
1782
1782
// the span we're aiming at correspond to a `fn` body.
1783
1783
if block_sp == blk. span {
1784
1784
sp = ret_sp;
1785
- fn_span = Some ( ident . span ) ;
1785
+ fn_span = self . tcx . def_ident_span ( fn_def_id ) ;
1786
1786
}
1787
1787
}
1788
1788
}
@@ -1897,15 +1897,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
1897
1897
None
1898
1898
}
1899
1899
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
-
1909
1900
/// If `expr` is a `match` expression that has only one non-`!` arm, use that arm's tail
1910
1901
/// expression's `Span`, otherwise return `expr.span`. This is done to give better errors
1911
1902
/// when given code like the following:
0 commit comments