Skip to content

Commit

Permalink
Fix clippy::drop_ref lint
Browse files Browse the repository at this point in the history
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 <eliza@buoyant.io>
  • Loading branch information
hawkw committed Oct 15, 2021
1 parent acd1a7e commit 0e12f69
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions valuable/src/visit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ pub trait Visit {
/// valuable::visit(&my_struct, &mut Print);
/// ```
fn visit_named_fields(&mut self, named_values: &NamedValues<'_>) {
drop(named_values);
let _ = named_values;
}

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

/// Visit a primitive slice.
Expand Down Expand Up @@ -359,7 +359,7 @@ pub trait Visit {
/// valuable::visit(&map, &mut Print);
/// ```
fn visit_entry(&mut self, key: Value<'_>, value: Value<'_>) {
drop((key, value));
let _ = (key, value);
}
}

Expand Down

0 comments on commit 0e12f69

Please sign in to comment.