compiler: Lower fn call arg spans down to MIR

To enable improved accuracy of diagnostics in upcoming commits.
This commit is contained in:
Martin Nordholts 2024-01-12 08:21:42 +01:00
parent 5a45dbe2e6
commit 6a74a0e17b
3 changed files with 4 additions and 4 deletions

View File

@ -257,9 +257,9 @@ fn is_call_with_ref_arg<'tcx>(
..
} = kind
&& 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 (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)
{
Some((def_id, *local, inner_ty, destination.as_local()?))

View File

@ -104,7 +104,7 @@ impl<'a, 'b, 'tcx> mir::visit::Visitor<'tcx> for PossibleBorrowerVisitor<'a, 'b,
let mut mutable_borrowers = vec![];
for op in args {
match op {
match &op.node {
mir::Operand::Copy(p) | mir::Operand::Move(p) => {
if let ty::Ref(_, _, Mutability::Mut) = self.body.local_decls[p.local].ty.kind() {
mutable_borrowers.push(p.local);

View File

@ -345,7 +345,7 @@ fn check_terminator<'tcx>(
check_operand(tcx, func, span, body)?;
for arg in args {
check_operand(tcx, arg, span, body)?;
check_operand(tcx, &arg.node, span, body)?;
}
Ok(())
} else {