about summary refs log tree commit diff
path: root/compiler/rustc_mir/src/transform/coverage/debug.rs
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2020-10-24 22:31:53 +0000
committerbors <bors@rust-lang.org>2020-10-24 22:31:53 +0000
commit5c78d26e5e4d96d346e9c365b71ad59449782958 (patch)
treee44754476bfa54b2653876320268d15282f0b7c1 /compiler/rustc_mir/src/transform/coverage/debug.rs
parentbf1c6f9871f430e284b17aa44059e0d0395e28a6 (diff)
parente8731a926c9a642ca1ddf5b52baf40e0a8873d53 (diff)
downloadrust-5c78d26e5e4d96d346e9c365b71ad59449782958.tar.gz
rust-5c78d26e5e4d96d346e9c365b71ad59449782958.zip
Auto merge of #6135 - cauebs:master, r=ebroto
Add large_types_passed_by_value lint

Creates a new lint that checks for large function parameters passed by value. ~Types that are Copy were ignored, because I understand they are explicitly marked as being cheap (or just acceptable) to copy. Arrays were excluded from that restriction because they are always Copy, independently of the size, if the elements are Copy.~ Only Copy types are considered, because if a type is not Copy it cannot be dereferenced, as pointed out by `@ebroto,` and that would require analyzing the whole function body to check if the argument is moved somewhere else. `self` and `mut` parameters are also skipped.

I refactored `trivially_copy_pass_by_ref` and the new lint into a new `pass_by_ref_or_value` module, since both share most of their implementations, as was pointed out to me in #4499.

~Some questions that remain:~
~1. Should `self` be disregarded for this lint?~
~2. Should we special case types like Vec and String when suggesting changes? (to slices and &str)~
~3. What should be the default size limit?~
~4. Are there any special cases I'm missing?~

I ask the maintainers to add the `hacktoberfest-accepted` label if this PR is decent, even if there are some minor details to work out, but I do intend to stick around and finish the job.

Fixes #4499

changelog: Add new lint [`large_types_passed_by_value`]
Diffstat (limited to 'compiler/rustc_mir/src/transform/coverage/debug.rs')
0 files changed, 0 insertions, 0 deletions