Description
The derived Clone implementations in Firefox weigh 192k [1], which is a lot.
Of that 192k, 79k of that is just for PropertyDeclaration::clone. PropertyDeclaration is a very large enum, but most of the variants are simple POD types. Ideally Rust would coalesce those together, and then generate special cases for the types that need it. Unfortunately, it appears that adding a single non-POD variant causes all the cases to be enumerated separately, as seen in the testcase at [2].
From IRC:
eddyb bholley: yeah I think this is a valid issue
eddyb: if you do generate that sort of "(partial) identity match" it's unlikely to have anything else collapse it
eddyb: LLVM might have a pass for switch-discriminant-dependent-values
eddyb: but it probably has serious limitations in practice
eddyb: bholley: but yeah this is one of those cases where not scattering in the first place is significantly easier than gathering later`
Ideally we'd do the same for PartialEq, since PropertyDeclaration::eq weighs another 61k.
[1] nm --print-size --size-sort --radix=d libxul.so | grep "..Clone" | grep -v Cloned | cut -d " " -f 2 | awk '{s+=$1} END {print s}'
[2] https://play.rust-lang.org/?gist=0207af76d2e05acdbed913b7df96aa77&version=stable