Skip to content

Commit b44197a

Browse files
committedSep 5, 2022
Auto merge of #101261 - TaKO8Ki:separate-receiver-from-arguments-in-hir, r=cjgillot
Separate the receiver from arguments in HIR Related to #100232 cc `@cjgillot`
2 parents 2dc703f + 9cde34e commit b44197a

File tree

140 files changed

+815
-720
lines changed

Some content is hidden

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

140 files changed

+815
-720
lines changed
 

‎compiler/rustc_ast_lowering/src/expr.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,10 @@ impl<'hir> LoweringContext<'_, 'hir> {
6868
ParenthesizedGenericArgs::Err,
6969
ImplTraitContext::Disallowed(ImplTraitPosition::Path),
7070
));
71-
let args = self.arena.alloc_from_iter(
72-
[&*receiver].into_iter().chain(args.iter()).map(|x| self.lower_expr_mut(x)),
73-
);
74-
hir::ExprKind::MethodCall(hir_seg, args, self.lower_span(span))
71+
let receiver = self.lower_expr(receiver);
72+
let args =
73+
self.arena.alloc_from_iter(args.iter().map(|x| self.lower_expr_mut(x)));
74+
hir::ExprKind::MethodCall(hir_seg, receiver, args, self.lower_span(span))
7575
}
7676
ExprKind::Binary(binop, ref lhs, ref rhs) => {
7777
let binop = self.lower_binop(binop);

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

+4-8
Original file line numberDiff line numberDiff line change
@@ -711,8 +711,8 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
711711
Applicability::MachineApplicable,
712712
);
713713
self.suggested = true;
714-
} else if let hir::ExprKind::MethodCall(_path, args @ [_, ..], sp) = expr.kind
715-
&& let hir::ExprKind::Index(val, index) = args[0].kind
714+
} else if let hir::ExprKind::MethodCall(_path, receiver, _, sp) = expr.kind
715+
&& let hir::ExprKind::Index(val, index) = receiver.kind
716716
&& expr.span == self.assign_span
717717
{
718718
// val[index].path(args..);
@@ -724,7 +724,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
724724
".get_mut(".to_string(),
725725
),
726726
(
727-
index.span.shrink_to_hi().with_hi(args[0].span.hi()),
727+
index.span.shrink_to_hi().with_hi(receiver.span.hi()),
728728
").map(|val| val".to_string(),
729729
),
730730
(sp.shrink_to_hi(), ")".to_string()),
@@ -911,11 +911,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
911911
[
912912
Expr {
913913
kind:
914-
MethodCall(
915-
path_segment,
916-
_args,
917-
span,
918-
),
914+
MethodCall(path_segment, _, _, span),
919915
hir_id,
920916
..
921917
},

0 commit comments

Comments
 (0)
Please sign in to comment.