compiler: Lower fn call arg spans down to MIR
To enable improved accuracy of diagnostics in upcoming commits.
This commit is contained in:
parent
5a45dbe2e6
commit
6a74a0e17b
@ -257,9 +257,9 @@ fn is_call_with_ref_arg<'tcx>(
|
|||||||
..
|
..
|
||||||
} = kind
|
} = kind
|
||||||
&& args.len() == 1
|
&& args.len() == 1
|
||||||
&& let mir::Operand::Move(mir::Place { local, .. }) = &args[0]
|
&& let mir::Operand::Move(mir::Place { local, .. }) = &args[0].node
|
||||||
&& let ty::FnDef(def_id, _) = *func.ty(mir, cx.tcx).kind()
|
&& let ty::FnDef(def_id, _) = *func.ty(mir, cx.tcx).kind()
|
||||||
&& let (inner_ty, 1) = walk_ptrs_ty_depth(args[0].ty(mir, cx.tcx))
|
&& let (inner_ty, 1) = walk_ptrs_ty_depth(args[0].node.ty(mir, cx.tcx))
|
||||||
&& !is_copy(cx, inner_ty)
|
&& !is_copy(cx, inner_ty)
|
||||||
{
|
{
|
||||||
Some((def_id, *local, inner_ty, destination.as_local()?))
|
Some((def_id, *local, inner_ty, destination.as_local()?))
|
||||||
|
@ -104,7 +104,7 @@ impl<'a, 'b, 'tcx> mir::visit::Visitor<'tcx> for PossibleBorrowerVisitor<'a, 'b,
|
|||||||
let mut mutable_borrowers = vec![];
|
let mut mutable_borrowers = vec![];
|
||||||
|
|
||||||
for op in args {
|
for op in args {
|
||||||
match op {
|
match &op.node {
|
||||||
mir::Operand::Copy(p) | mir::Operand::Move(p) => {
|
mir::Operand::Copy(p) | mir::Operand::Move(p) => {
|
||||||
if let ty::Ref(_, _, Mutability::Mut) = self.body.local_decls[p.local].ty.kind() {
|
if let ty::Ref(_, _, Mutability::Mut) = self.body.local_decls[p.local].ty.kind() {
|
||||||
mutable_borrowers.push(p.local);
|
mutable_borrowers.push(p.local);
|
||||||
|
@ -345,7 +345,7 @@ fn check_terminator<'tcx>(
|
|||||||
check_operand(tcx, func, span, body)?;
|
check_operand(tcx, func, span, body)?;
|
||||||
|
|
||||||
for arg in args {
|
for arg in args {
|
||||||
check_operand(tcx, arg, span, body)?;
|
check_operand(tcx, &arg.node, span, body)?;
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user