From 41d24ccb49102bf6e2bfb5828f6d67abd8961e00 Mon Sep 17 00:00:00 2001 From: Martin Nordholts Date: Sun, 1 Oct 2023 08:51:47 +0200 Subject: [PATCH] rustc_monomorphize: Move limit check into check_move_size() And rename to check_operand_move_size(). Later we will introduce check_fn_args_move_size(). --- compiler/rustc_monomorphize/src/collector.rs | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/compiler/rustc_monomorphize/src/collector.rs b/compiler/rustc_monomorphize/src/collector.rs index 8525a4e74c2..0ec723cb0e3 100644 --- a/compiler/rustc_monomorphize/src/collector.rs +++ b/compiler/rustc_monomorphize/src/collector.rs @@ -613,7 +613,15 @@ impl<'a, 'tcx> MirUsedCollector<'a, 'tcx> { ) } - fn check_move_size(&mut self, limit: usize, operand: &mir::Operand<'tcx>, location: Location) { + fn check_operand_move_size(&mut self, operand: &mir::Operand<'tcx>, location: Location) { + if self.skip_move_size_check { + return; + } + let limit = self.tcx.move_size_limit().0; + if limit == 0 { + return; + } + let limit = Size::from_bytes(limit); let ty = operand.ty(self.body, self.tcx); let ty = self.monomorphize(ty); @@ -841,10 +849,7 @@ impl<'a, 'tcx> MirVisitor<'tcx> for MirUsedCollector<'a, 'tcx> { fn visit_operand(&mut self, operand: &mir::Operand<'tcx>, location: Location) { self.super_operand(operand, location); - let move_size_limit = self.tcx.move_size_limit().0; - if move_size_limit > 0 && !self.skip_move_size_check { - self.check_move_size(move_size_limit, operand, location); - } + self.check_operand_move_size(operand, location); } fn visit_local(