Skip to content

Commit 9f4230c

Browse files
Remove get_parent_fn_decl; it's redundant
1 parent 4d570ee commit 9f4230c

File tree

2 files changed

+3
-12
lines changed
  • compiler

2 files changed

+3
-12
lines changed

compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1771,15 +1771,15 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
17711771
// that highlight errors inline.
17721772
let mut sp = blk.span;
17731773
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) {
17751775
let ret_sp = decl.output.span();
17761776
if let Some(block_sp) = self.parent_item_span(blk.hir_id) {
17771777
// HACK: on some cases (`ui/liveness/liveness-issue-2163.rs`) the
17781778
// output would otherwise be incorrect and even misleading. Make sure
17791779
// the span we're aiming at correspond to a `fn` body.
17801780
if block_sp == blk.span {
17811781
sp = ret_sp;
1782-
fn_span = Some(ident.span);
1782+
fn_span = self.tcx.def_ident_span(fn_def_id);
17831783
}
17841784
}
17851785
}
@@ -1894,15 +1894,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
18941894
None
18951895
}
18961896

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-
19061897
/// If `expr` is a `match` expression that has only one non-`!` arm, use that arm's tail
19071898
/// expression's `Span`, otherwise return `expr.span`. This is done to give better errors
19081899
/// when given code like the following:

compiler/rustc_middle/src/hir/map/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -511,7 +511,7 @@ impl<'hir> Map<'hir> {
511511
self.body_const_context(self.enclosing_body_owner(hir_id)).is_some()
512512
}
513513

514-
/// Retrieves the `HirId` for `id`'s enclosing method, unless there's a
514+
/// Retrieves the `HirId` for `id`'s enclosing method's body, unless there's a
515515
/// `while` or `loop` before reaching it, as block tail returns are not
516516
/// available in them.
517517
///

0 commit comments

Comments
 (0)