Skip to content

Commit 78d14a9

Browse files
committed
Fix large_types_passed_by_value example and improve docs
1 parent ae7c2cb commit 78d14a9

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

clippy_lints/src/pass_by_ref_or_value.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,9 @@ declare_clippy_lint! {
6161
/// because that might induce API breakage, if the parameter is declared as mutable,
6262
/// or if the argument is a `self`.
6363
///
64-
/// **Why is this bad?** Arguments passed by value might require a shallow copy,
65-
/// which can be expensive and can be easily improved with passing by reference.
64+
/// **Why is this bad?** Arguments passed by value might result in an unnecessary
65+
/// shallow copy, taking up more space in the stack and requiring a call to
66+
/// `memcpy`, which which can be expensive.
6667
///
6768
/// **Example:**
6869
///
@@ -73,9 +74,11 @@ declare_clippy_lint! {
7374
/// // Bad
7475
/// fn foo(v: TooLarge) {}
7576
/// ```
76-
///
7777
/// ```rust
78-
/// // Better
78+
/// #[derive(Clone, Copy)]
79+
/// struct TooLarge([u8; 2048]);
80+
///
81+
/// // Good
7982
/// fn foo(v: &TooLarge) {}
8083
/// ```
8184
pub LARGE_TYPES_PASSED_BY_VALUE,

0 commit comments

Comments
 (0)