Skip to content

Commit 8305903

Browse files
Remove get_parent_fn_decl; it's redundant
1 parent 84e729a commit 8305903

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
@@ -1775,15 +1775,15 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
17751775
// that highlight errors inline.
17761776
let mut sp = blk.span;
17771777
let mut fn_span = None;
1778-
if let Some((decl, ident)) = self.get_parent_fn_decl(blk.hir_id) {
1778+
if let Some((fn_def_id, decl, _)) = self.get_fn_decl(blk.hir_id) {
17791779
let ret_sp = decl.output.span();
17801780
if let Some(block_sp) = self.parent_item_span(blk.hir_id) {
17811781
// HACK: on some cases (`ui/liveness/liveness-issue-2163.rs`) the
17821782
// output would otherwise be incorrect and even misleading. Make sure
17831783
// the span we're aiming at correspond to a `fn` body.
17841784
if block_sp == blk.span {
17851785
sp = ret_sp;
1786-
fn_span = Some(ident.span);
1786+
fn_span = self.tcx.def_ident_span(fn_def_id);
17871787
}
17881788
}
17891789
}
@@ -1898,15 +1898,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
18981898
None
18991899
}
19001900

1901-
/// Given a function block's `HirId`, returns its `FnDecl` if it exists, or `None` otherwise.
1902-
pub(crate) fn get_parent_fn_decl(
1903-
&self,
1904-
blk_id: hir::HirId,
1905-
) -> Option<(&'tcx hir::FnDecl<'tcx>, Ident)> {
1906-
let parent = self.tcx.hir_node_by_def_id(self.tcx.hir().get_parent_item(blk_id).def_id);
1907-
self.get_node_fn_decl(parent).map(|(_, fn_decl, ident, _)| (fn_decl, ident))
1908-
}
1909-
19101901
/// If `expr` is a `match` expression that has only one non-`!` arm, use that arm's tail
19111902
/// expression's `Span`, otherwise return `expr.span`. This is done to give better errors
19121903
/// 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
@@ -510,7 +510,7 @@ impl<'hir> Map<'hir> {
510510
self.body_const_context(self.enclosing_body_owner(hir_id)).is_some()
511511
}
512512

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

0 commit comments

Comments
 (0)