Skip to content

Commit 8abd0b4

Browse files
authored
style(lib): enforce clippy::trivially_copy_pass_by_ref (#4252)
See #4071. Lint doc: https://clippy.rust-lang.org/master/index.html#trivially_copy_pass_by_ref The rule checks for functions taking arguments by reference, where the argument type is Copy and small enough to be more efficient to always pass by value. Only four functions were flagged by this rule, where `&self` was changed to `self`.
1 parent a8ab2c7 commit 8abd0b4

5 files changed

Lines changed: 6 additions & 7 deletions

File tree

‎Cargo.toml‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,6 @@ needless_pass_by_value = "allow"
127127
pattern_type_mismatch = "allow"
128128
redundant_else = "allow"
129129
struct_excessive_bools = "allow" # TODO: bogus lint?
130-
trivially_copy_pass_by_ref = "allow"
131130
unnested_or_patterns = "allow"
132131
unused_async = "allow" # TODO: is it for API?
133132
unused_trait_names = "allow" # TODO: kinda annoying, but might be good to deny

‎src/body/length.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ impl DecodedLength {
8181
///
8282
/// It would return false if "chunked" or otherwise size-unknown.
8383
#[cfg(all(any(feature = "client", feature = "server"), feature = "http2"))]
84-
pub(crate) fn is_exact(&self) -> bool {
84+
pub(crate) fn is_exact(self) -> bool {
8585
self.0 <= MAX_LEN
8686
}
8787
}

‎src/proto/h1/conn.rs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1068,8 +1068,8 @@ impl KA {
10681068
*self = KA::Disabled;
10691069
}
10701070

1071-
fn status(&self) -> KA {
1072-
*self
1071+
fn status(self) -> KA {
1072+
self
10731073
}
10741074
}
10751075

‎src/proto/h1/decode.rs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ impl ChunkedState {
301301
ChunkedState::Start
302302
}
303303
fn step<R: MemRead>(
304-
&self,
304+
self,
305305
cx: &mut Context<'_>,
306306
body: &mut R,
307307
StepArgs {
@@ -318,7 +318,7 @@ impl ChunkedState {
318318
Body, BodyCr, BodyLf, End, EndCr, EndLf, Extension, Size, SizeLf, SizeLws, Start,
319319
Trailer, TrailerLf,
320320
};
321-
match *self {
321+
match self {
322322
Start => ChunkedState::read_start(cx, body, chunk_size),
323323
Size => ChunkedState::read_size(cx, body, chunk_size),
324324
SizeLws => ChunkedState::read_size_lws(cx, body),

‎src/proto/h1/mod.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ impl Wants {
108108
Wants(self.0 | other.0)
109109
}
110110

111-
fn contains(&self, other: Wants) -> bool {
111+
fn contains(self, other: Wants) -> bool {
112112
(self.0 & other.0) == other.0
113113
}
114114
}

0 commit comments

Comments
 (0)