1
Fork 0

Rollup merge of #120773 - Enselic:copy-vs-move, r=oli-obk

large_assignments: Allow moves into functions

Moves into functions are typically implemented with pointer passing
rather than memcpy's at the llvm-ir level, so allow moves into
functions.

Part of the "Differentiate between Operand::Move and Operand::Copy" step of https://github.com/rust-lang/rust/issues/83518.

r? `@oli-obk` (who I think is still E-mentor?)
This commit is contained in:
Matthias Krüger 2024-02-11 01:37:55 +01:00 committed by GitHub
commit fd287d2e88
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 147 additions and 38 deletions

View file

@ -666,7 +666,15 @@ impl<'a, 'tcx> MirUsedCollector<'a, 'tcx> {
debug!(?def_id, ?fn_span);
for arg in args {
if let Some(too_large_size) = self.operand_size_if_too_large(limit, &arg.node) {
// Moving args into functions is typically implemented with pointer
// passing at the llvm-ir level and not by memcpy's. So always allow
// moving args into functions.
let operand: &mir::Operand<'tcx> = &arg.node;
if let mir::Operand::Move(_) = operand {
continue;
}
if let Some(too_large_size) = self.operand_size_if_too_large(limit, operand) {
self.lint_large_assignment(limit.0, too_large_size, location, arg.span);
};
}