Skip to content

Commit b826eb2

Browse files
Rename confusing function name
1 parent d2dabee commit b826eb2

File tree

4 files changed

+9
-9
lines changed

4 files changed

+9
-9
lines changed

compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -992,7 +992,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
992992
}
993993
}
994994

995-
if look_at_return && hir.get_return_block(closure_id).is_some() {
995+
if look_at_return && hir.get_fn_id_for_return_block(closure_id).is_some() {
996996
// ...otherwise we are probably in the tail expression of the function, point at the
997997
// return type.
998998
match self.infcx.tcx.hir_node_by_def_id(hir.get_parent_item(fn_call_id).def_id) {

compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -944,7 +944,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
944944
) -> Option<(LocalDefId, &'tcx hir::FnDecl<'tcx>, bool)> {
945945
// Get enclosing Fn, if it is a function or a trait method, unless there's a `loop` or
946946
// `while` before reaching it, as block tail returns are not available in them.
947-
self.tcx.hir().get_return_block(blk_id).and_then(|blk_id| {
947+
self.tcx.hir().get_fn_id_for_return_block(blk_id).and_then(|blk_id| {
948948
let parent = self.tcx.hir_node(blk_id);
949949
self.get_node_fn_decl(parent)
950950
.map(|(fn_id, fn_decl, _, is_main)| (fn_id, fn_decl, is_main))

compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1909,7 +1909,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
19091909
let returned = matches!(
19101910
self.tcx.parent_hir_node(expr.hir_id),
19111911
hir::Node::Expr(hir::Expr { kind: hir::ExprKind::Ret(_), .. })
1912-
) || map.get_return_block(expr.hir_id).is_some();
1912+
) || map.get_fn_id_for_return_block(expr.hir_id).is_some();
19131913
if returned
19141914
&& let ty::Adt(e, args_e) = expected.kind()
19151915
&& let ty::Adt(f, args_f) = found.kind()

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

+6-6
Original file line numberDiff line numberDiff line change
@@ -511,14 +511,14 @@ 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's body, unless there's a
515-
/// `while` or `loop` before reaching it, as block tail returns are not
516-
/// available in them.
514+
/// Retrieves the `HirId` for `id`'s enclosing function *if* the `id` block or return is
515+
/// in the "tail" position of the function, in other words if it's likely to correspond
516+
/// to the return type of the function.
517517
///
518518
/// ```
519519
/// fn foo(x: usize) -> bool {
520520
/// if x == 1 {
521-
/// true // If `get_return_block` gets passed the `id` corresponding
521+
/// true // If `get_fn_id_for_return_block` gets passed the `id` corresponding
522522
/// } else { // to this, it will return `foo`'s `HirId`.
523523
/// false
524524
/// }
@@ -528,12 +528,12 @@ impl<'hir> Map<'hir> {
528528
/// ```compile_fail,E0308
529529
/// fn foo(x: usize) -> bool {
530530
/// loop {
531-
/// true // If `get_return_block` gets passed the `id` corresponding
531+
/// true // If `get_fn_id_for_return_block` gets passed the `id` corresponding
532532
/// } // to this, it will return `None`.
533533
/// false
534534
/// }
535535
/// ```
536-
pub fn get_return_block(self, id: HirId) -> Option<HirId> {
536+
pub fn get_fn_id_for_return_block(self, id: HirId) -> Option<HirId> {
537537
let mut iter = self.parent_iter(id).peekable();
538538
let mut ignore_tail = false;
539539
if let Node::Expr(Expr { kind: ExprKind::Ret(_), .. }) = self.tcx.hir_node(id) {

0 commit comments

Comments
 (0)