Size a copied constant's children with size_of_val

clippy's manual_slice_size_calculation (rust 1.98) stopped the
workspace's clippy at copy_bytes, the linked-module copy's ledger
estimate: size_of::<ConstId>() * children().len() over the slice
children() returns. The same bytes, as size_of_val of that slice.

Verified: cargo clippy --workspace --all-targets --all-features
-D warnings, plain and under --cfg m2v_gpu (own target), clean; rustdoc
-D warnings for the workspace, clean.

(Carried to development from steelbrain/reims-graphics-kext d232492977.)
This commit is contained in:
Anees Iqbal committed 2026-11-01 21:26:18 -08:00
1 parent e54a2c12aa
commit 468a91feab
1 file changed
+1 -2
+1 -2
View File
@@ -1062,8 +1062,7 @@ fn copy_bytes(parts: &ModuleParts) -> usize {
.fold(0usize, |n, b| n.saturating_add(b.footprint()));
let consts = parts.consts.iter().fold(0usize, |n, (_, c)| {
n.saturating_add(
std::mem::size_of::<crate::ir::Constant>()
+ std::mem::size_of::<ConstId>() * c.value.children().len(),
std::mem::size_of::<crate::ir::Constant>() + std::mem::size_of_val(c.value.children()),
)
});
let strings = (0..parts.symbols.len())