You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Passing BlockHeader by value triggers the clippy::large_types_passed_by_value pedantic lint, because it is both Copy and "large" at 334 bytes.
There is a general rust argument that all types can derive Copy, should. The argument goes that the only real distinction from Clone is whether one can continue to use the sender side after passing by value, and therefore Copy is always good if one can derive it trivially.
Something this argument glosses over though, is that Clone marks places which one can audit for expensive copies. The above lint is supposed to catch such instances - however it suppresses this lint for pub fn to avoid api breaking suggestions. This suppression can be disabled by configuring avoid-breaking-exported-api=false.
We should decide whether to:
Remove Copy from large types, or
Enforce the lint and disable api-breakage suppression, or
Do both (1) and (2)
I'd suggest (3) because I like my lints, and I like seeing where large copies happen. I was originally going to suggest (1) only, but I can actually see the ergonomics behind doing just (2). The biggest downside of (2) being that users of our crates have to also opt-in to the lints to get the "benefits".
The text was updated successfully, but these errors were encountered:
I think we should be notified if a type gets too large so we can reevaluate whether Copy makes sense or not. Since we're not at a 1.X yet, I think we can reserve the right to make changes like remove Copy from large types. Even with a 1.X released, we should at least get notified via the lint and then we can always selectively allow it. At that point we should use something like https://github.com/obi1kenobi/cargo-semver-checks anyway to review changes to the public API between PRs so that breaking the API would be hard to do accidentally.
Passing
BlockHeader
by value triggers theclippy::large_types_passed_by_value
pedantic lint, because it is bothCopy
and "large" at 334 bytes.There is a general rust argument that all types can derive
Copy
, should. The argument goes that the only real distinction fromClone
is whether one can continue to use the sender side after passing by value, and thereforeCopy
is always good if one can derive it trivially.Something this argument glosses over though, is that
Clone
marks places which one can audit for expensive copies. The above lint is supposed to catch such instances - however it suppresses this lint forpub fn
to avoid api breaking suggestions. This suppression can be disabled by configuringavoid-breaking-exported-api=false
.We should decide whether to:
Copy
from large types, orI'd suggest (3) because I like my lints, and I like seeing where large copies happen. I was originally going to suggest (1) only, but I can actually see the ergonomics behind doing just (2). The biggest downside of (2) being that users of our crates have to also opt-in to the lints to get the "benefits".
The text was updated successfully, but these errors were encountered: