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 92f2e0a

Browse files
committedJan 16, 2024
Auto merge of rust-lang#116520 - Enselic:large-copy-into-fn, r=oli-obk
large_assignments: Lint on specific large args passed to functions Requires lowering function call arg spans down to MIR, which is done in the second commit. Part of rust-lang#83518 Also see * https://rust-lang.zulipchat.com/#narrow/stream/182449-t-compiler.2Fhelp/topic/arg.20Spans.20for.20TerminatorKind.3A.3ACall.3F * https://rust-lang.zulipchat.com/#narrow/stream/122651-general/topic/move_size_limit.20lint r? `@oli-obk` (E-mentor)
2 parents e64f849 + 8f440f0 commit 92f2e0a

File tree

52 files changed

+379
-210
lines changed

Some content is hidden

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

52 files changed

+379
-210
lines changed
 

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1257,7 +1257,10 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
12571257
return None;
12581258
};
12591259
debug!("checking call args for uses of inner_param: {:?}", args);
1260-
args.contains(&Operand::Move(inner_param)).then_some((loc, term))
1260+
args.iter()
1261+
.map(|a| &a.node)
1262+
.any(|a| a == &Operand::Move(inner_param))
1263+
.then_some((loc, term))
12611264
})
12621265
else {
12631266
debug!("no uses of inner_param found as a by-move call arg");
@@ -3242,7 +3245,8 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
32423245
assigned_to, args
32433246
);
32443247
for operand in args {
3245-
let (Operand::Copy(assigned_from) | Operand::Move(assigned_from)) = operand
3248+
let (Operand::Copy(assigned_from) | Operand::Move(assigned_from)) =
3249+
&operand.node
32463250
else {
32473251
continue;
32483252
};

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -691,7 +691,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
691691
);
692692
// Check if one of the arguments to this function is the target place.
693693
let found_target = args.iter().any(|arg| {
694-
if let Operand::Move(place) = arg {
694+
if let Operand::Move(place) = arg.node {
695695
if let Some(potential) = place.as_local() {
696696
potential == target
697697
} else {

0 commit comments

Comments
 (0)
Please sign in to comment.