Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 8f6888a

Browse files
authoredFeb 12, 2024··
Unrolled build for rust-lang#120872
Rollup merge of rust-lang#120872 - petrochenkov:opthirpar, r=cjgillot hir: Refactor getters for HIR parents See individual commits. I ended up removing on of the FIXMEs from rust-lang#120206 instead of addressing it.
2 parents 520b0b2 + b072838 commit 8f6888a

File tree

79 files changed

+263
-342
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

79 files changed

+263
-342
lines changed
 

‎compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -403,8 +403,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
403403
}
404404
}
405405
let typeck = self.infcx.tcx.typeck(self.mir_def_id());
406-
let hir_id = hir.parent_id(expr.hir_id);
407-
let parent = self.infcx.tcx.hir_node(hir_id);
406+
let parent = self.infcx.tcx.parent_hir_node(expr.hir_id);
408407
let (def_id, args, offset) = if let hir::Node::Expr(parent_expr) = parent
409408
&& let hir::ExprKind::MethodCall(_, _, args, _) = parent_expr.kind
410409
&& let Some(def_id) = typeck.type_dependent_def_id(parent_expr.hir_id)
@@ -1660,8 +1659,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
16601659

16611660
// Check that the parent of the closure is a method call,
16621661
// with receiver matching with local's type (modulo refs)
1663-
let parent = hir.parent_id(closure_expr.hir_id);
1664-
if let hir::Node::Expr(parent) = tcx.hir_node(parent) {
1662+
if let hir::Node::Expr(parent) = tcx.parent_hir_node(closure_expr.hir_id) {
16651663
if let hir::ExprKind::MethodCall(_, recv, ..) = parent.kind {
16661664
let recv_ty = typeck_results.expr_ty(recv);
16671665

‎compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -944,7 +944,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
944944
let hir = self.infcx.tcx.hir();
945945
let closure_id = self.mir_hir_id();
946946
let closure_span = self.infcx.tcx.def_span(self.mir_def_id());
947-
let fn_call_id = hir.parent_id(closure_id);
947+
let fn_call_id = self.infcx.tcx.parent_hir_id(closure_id);
948948
let node = self.infcx.tcx.hir_node(fn_call_id);
949949
let def_id = hir.enclosing_body_owner(fn_call_id);
950950
let mut look_at_return = true;
@@ -1034,7 +1034,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
10341034
if let InstanceDef::Item(def_id) = source.instance
10351035
&& let Some(Node::Expr(hir::Expr { hir_id, kind, .. })) = hir.get_if_local(def_id)
10361036
&& let ExprKind::Closure(hir::Closure { kind: hir::ClosureKind::Closure, .. }) = kind
1037-
&& let Some(Node::Expr(expr)) = hir.find_parent(*hir_id)
1037+
&& let Node::Expr(expr) = self.infcx.tcx.parent_hir_node(*hir_id)
10381038
{
10391039
let mut cur_expr = expr;
10401040
while let ExprKind::MethodCall(path_segment, recv, _, _) = cur_expr.kind {

0 commit comments

Comments
 (0)
Please sign in to comment.