G.FUD.02 Should input as reference if parameter derives Copy and its value inputed by-value is a big number

[Level] Advice

[Description]

By-value inputed parameters may emerge unnecessary memcpy, which could kill performance.

[Bad Case]


#![allow(unused)]
#![warn(clippy::large_types_passed_by_value)]

fn main() {
#[derive(Clone, Copy)]
struct TooLarge([u8; 2048]);

// Not Good
fn foo(v: TooLarge) {}
}

[Good Case]


#![allow(unused)]
#![warn(clippy::large_types_passed_by_value)]

fn main() {
#[derive(Clone, Copy)]
struct TooLarge([u8; 2048]);

// Good
fn foo(v: &TooLarge) {}
}

[Lint Check]

lint nameClippy checkRustc checkLint GroupLevel
large_types_passed_by_valueyesnopedanicallow

This lint corresponds to the following configuration of clippy.toml

# if function is an exported api, then the lint would not be triggered, which aims to prevent devastated change for api. the default is true.
avoid-breaking-exported-api=true