-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add trivially_copy_pass_by_ref
to the lint set.
#73
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems reasonable; some small concerns about metadata
// See https://linebender.org/wiki/canonical-lints/ | ||
// These lints aren't included in Cargo.toml because they | ||
// shouldn't apply to examples and tests | ||
#![warn(unused_crate_dependencies)] | ||
#![warn(clippy::print_stdout, clippy::print_stderr)] | ||
// END LINEBENDER LINT SET |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Previous discussion here #68 (comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The rustfmt problem is valid, but looking at this in the wild it's not immediately obvious where the set ends. I'll need to think about this a bit more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah. I think the problem comes if there are no other trailing attributes; we want this to come after crate level docs, so it's plausible that there'd be no other attributes.
Maybe the solution is for the pattern to be:
// LINEBENDER LINT SET ...
...
// END LINEBENDER LINT SET
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like it, as we want that present everywhere anyway.
This is an old standard lint from the Druid days, still enabled for Druid, Piet, Kurbo, Xilem, and was just removed from Parley two days ago which triggered this PR.
I think it makes sense to keep it as part of the standard set. It helps detect potential micro-optimizations. The default Clippy configuration option
avoid-breaking-exported-api
istrue
which means it won't affect the public API.The main downside is that if we have a tiny struct which gets suggested for copy and then later that struct grows larger, we will need to manually update the methods to take a reference instead. Probably a good idea to add a code comment for potential growers about this.
The
trivial-copy-size-limit
configuration of 16 bytes is also a continuation of an old decision. The rationale for optimizing for 64-bit is even more true today with even low-end mobile phones having 64-bit CPUs.I also bumped the linebender lint set version, but only for the
Cargo.toml
bunch. I think it can only cause wasted effort to bump the version in other files that have zero changes.