@@ -1771,15 +1771,15 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
1771
1771
// that highlight errors inline.
1772
1772
let mut sp = blk. span ;
1773
1773
let mut fn_span = None ;
1774
- if let Some ( ( decl, ident ) ) = self . get_parent_fn_decl ( blk. hir_id ) {
1774
+ if let Some ( ( fn_def_id , decl, _ ) ) = self . get_fn_decl ( blk. hir_id ) {
1775
1775
let ret_sp = decl. output . span ( ) ;
1776
1776
if let Some ( block_sp) = self . parent_item_span ( blk. hir_id ) {
1777
1777
// HACK: on some cases (`ui/liveness/liveness-issue-2163.rs`) the
1778
1778
// output would otherwise be incorrect and even misleading. Make sure
1779
1779
// the span we're aiming at correspond to a `fn` body.
1780
1780
if block_sp == blk. span {
1781
1781
sp = ret_sp;
1782
- fn_span = Some ( ident . span ) ;
1782
+ fn_span = self . tcx . def_ident_span ( fn_def_id ) ;
1783
1783
}
1784
1784
}
1785
1785
}
@@ -1894,15 +1894,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
1894
1894
None
1895
1895
}
1896
1896
1897
- /// Given a function block's `HirId`, returns its `FnDecl` if it exists, or `None` otherwise.
1898
- pub ( crate ) fn get_parent_fn_decl (
1899
- & self ,
1900
- blk_id : HirId ,
1901
- ) -> Option < ( & ' tcx hir:: FnDecl < ' tcx > , Ident ) > {
1902
- let parent = self . tcx . hir_node_by_def_id ( self . tcx . hir ( ) . get_parent_item ( blk_id) . def_id ) ;
1903
- self . get_node_fn_decl ( parent) . map ( |( _, fn_decl, ident, _) | ( fn_decl, ident) )
1904
- }
1905
-
1906
1897
/// If `expr` is a `match` expression that has only one non-`!` arm, use that arm's tail
1907
1898
/// expression's `Span`, otherwise return `expr.span`. This is done to give better errors
1908
1899
/// when given code like the following:
0 commit comments