separate the receiver from arguments in HIR
This commit is contained in:
parent
6e4a9ab650
commit
87c6da363f
27 changed files with 115 additions and 96 deletions
|
@ -711,8 +711,8 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
|
|||
Applicability::MachineApplicable,
|
||||
);
|
||||
self.suggested = true;
|
||||
} else if let hir::ExprKind::MethodCall(_path, args @ [_, ..], sp) = expr.kind
|
||||
&& let hir::ExprKind::Index(val, index) = args[0].kind
|
||||
} else if let hir::ExprKind::MethodCall(_path, receiver, _, sp) = expr.kind
|
||||
&& let hir::ExprKind::Index(val, index) = receiver.kind
|
||||
&& expr.span == self.assign_span
|
||||
{
|
||||
// val[index].path(args..);
|
||||
|
@ -724,7 +724,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
|
|||
".get_mut(".to_string(),
|
||||
),
|
||||
(
|
||||
index.span.shrink_to_hi().with_hi(args[0].span.hi()),
|
||||
index.span.shrink_to_hi().with_hi(receiver.span.hi()),
|
||||
").map(|val| val".to_string(),
|
||||
),
|
||||
(sp.shrink_to_hi(), ")".to_string()),
|
||||
|
@ -911,11 +911,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
|
|||
[
|
||||
Expr {
|
||||
kind:
|
||||
MethodCall(
|
||||
path_segment,
|
||||
_args,
|
||||
span,
|
||||
),
|
||||
MethodCall(path_segment, _, _, span),
|
||||
hir_id,
|
||||
..
|
||||
},
|
||||
|
|
|
@ -901,13 +901,13 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
|
|||
match expr.kind {
|
||||
hir::ExprKind::MethodCall(.., args, _) => {
|
||||
// only the first closre parameter of the method. args[0] is MethodCall PathSegment
|
||||
for i in 1..args.len() {
|
||||
|
||||
for arg in args {
|
||||
if let hir::ExprKind::Closure(hir::Closure {
|
||||
capture_clause: hir::CaptureBy::Ref,
|
||||
..
|
||||
}) = args[i].kind
|
||||
{
|
||||
closure_span = Some(args[i].span.shrink_to_lo());
|
||||
}) = arg.kind {
|
||||
closure_span = Some(arg.span.shrink_to_lo());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue