Skip to content

Commit 0e12f69

Browse files
committed
Fix clippy::drop_ref lint
Clippy doesn't like calls to `std::mem::drop` with references --- since the pointed value is not actually dropped. In this case, this *is* the correct behavior, but clippy views this as a footgun if the user means to actually drop the value behind the reference. Here, we're using `drop` to ignore values in no-op default impls for trait methods. I've changed those methods to use `let _` to ignore parameters instead. This doesn't trigger the clippy lint and is maybe more idiomatic anyway. Signed-off-by: Eliza Weisman <[email protected]>
1 parent acd1a7e commit 0e12f69

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

valuable/src/visit.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ pub trait Visit {
223223
/// valuable::visit(&my_struct, &mut Print);
224224
/// ```
225225
fn visit_named_fields(&mut self, named_values: &NamedValues<'_>) {
226-
drop(named_values);
226+
let _ = named_values;
227227
}
228228

229229
/// Visit a struct or enum's unnamed fields.
@@ -267,7 +267,7 @@ pub trait Visit {
267267
/// valuable::visit(&my_struct, &mut Print);
268268
/// ```
269269
fn visit_unnamed_fields(&mut self, values: &[Value<'_>]) {
270-
drop(values);
270+
let _ = values;
271271
}
272272

273273
/// Visit a primitive slice.
@@ -359,7 +359,7 @@ pub trait Visit {
359359
/// valuable::visit(&map, &mut Print);
360360
/// ```
361361
fn visit_entry(&mut self, key: Value<'_>, value: Value<'_>) {
362-
drop((key, value));
362+
let _ = (key, value);
363363
}
364364
}
365365

0 commit comments

Comments
 (0)