diff options
Diffstat (limited to 'src/tools/clippy/tests/ui/unit_hash.rs')
-rw-r--r-- | src/tools/clippy/tests/ui/unit_hash.rs | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/tools/clippy/tests/ui/unit_hash.rs b/src/tools/clippy/tests/ui/unit_hash.rs new file mode 100644 index 000000000..43eb54eff --- /dev/null +++ b/src/tools/clippy/tests/ui/unit_hash.rs @@ -0,0 +1,28 @@ +#![warn(clippy::unit_hash)] +#![allow(clippy::let_unit_value)] + +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), + Foo::WithValue(x) => x.hash(&mut state), + } + + let res = (); + res.hash(&mut state); + + #[allow(clippy::unit_arg)] + do_nothing().hash(&mut state); +} |