2021-11-04 12:52:36 +00:00
|
|
|
#![warn(clippy::unit_hash)]
|
2022-05-05 14:12:52 +00:00
|
|
|
#![allow(clippy::let_unit_value)]
|
2021-11-04 12:52:36 +00:00
|
|
|
|
|
|
|
use std::collections::hash_map::DefaultHasher;
|
|
|
|
use std::hash::Hash;
|
|
|
|
|
|
|
|
enum Foo {
|
|
|
|
Empty,
|
|
|
|
WithValue(u8),
|
|
|
|
}
|
|
|
|
|
|
|
|
fn do_nothing() {}
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
let mut state = DefaultHasher::new();
|
|
|
|
let my_enum = Foo::Empty;
|
|
|
|
|
|
|
|
match my_enum {
|
|
|
|
Foo::Empty => ().hash(&mut state),
|
2023-08-24 19:32:12 +00:00
|
|
|
//~^ ERROR: this call to `hash` on the unit type will do nothing
|
|
|
|
//~| NOTE: the implementation of `Hash` for `()` is a no-op
|
2021-11-04 12:52:36 +00:00
|
|
|
Foo::WithValue(x) => x.hash(&mut state),
|
|
|
|
}
|
|
|
|
|
|
|
|
let res = ();
|
|
|
|
res.hash(&mut state);
|
2023-08-24 19:32:12 +00:00
|
|
|
//~^ ERROR: this call to `hash` on the unit type will do nothing
|
|
|
|
//~| NOTE: the implementation of `Hash` for `()` is a no-op
|
2021-11-04 12:52:36 +00:00
|
|
|
|
|
|
|
#[allow(clippy::unit_arg)]
|
|
|
|
do_nothing().hash(&mut state);
|
2023-08-24 19:32:12 +00:00
|
|
|
//~^ ERROR: this call to `hash` on the unit type will do nothing
|
|
|
|
//~| NOTE: the implementation of `Hash` for `()` is a no-op
|
2021-11-04 12:52:36 +00:00
|
|
|
}
|