Skip to content

Commit e3b17cf

Browse files
Rename confusing function name
1 parent dc60dc0 commit e3b17cf

File tree

4 files changed

+9
-9
lines changed

4 files changed

+9
-9
lines changed

compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -991,7 +991,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
991991
}
992992
}
993993

994-
if look_at_return && hir.get_return_block(closure_id).is_some() {
994+
if look_at_return && hir.get_fn_id_for_return_block(closure_id).is_some() {
995995
// ...otherwise we are probably in the tail expression of the function, point at the
996996
// return type.
997997
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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1014,7 +1014,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
10141014
) -> Option<(LocalDefId, &'tcx hir::FnDecl<'tcx>, bool)> {
10151015
// Get enclosing Fn, if it is a function or a trait method, unless there's a `loop` or
10161016
// `while` before reaching it, as block tail returns are not available in them.
1017-
self.tcx.hir().get_return_block(blk_id).and_then(|blk_id| {
1017+
self.tcx.hir().get_fn_id_for_return_block(blk_id).and_then(|blk_id| {
10181018
let parent = self.tcx.hir_node(blk_id);
10191019
self.get_node_fn_decl(parent)
10201020
.map(|(fn_id, fn_decl, _, is_main)| (fn_id, fn_decl, is_main))

compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs

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

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

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

0 commit comments

Comments
 (0)