fork/rust

git clone https://git.julia.blue/fork/rust

borsAuto merge of #103046 - JanBeh:PR_clarify_cmp_terminology, r=workingjubilee3bcad65fbf6

master
915 B34 linesraw
1#![warn(clippy::unit_hash)]
2#![allow(clippy::let_unit_value)]
3
4use std::collections::hash_map::DefaultHasher;
5use std::hash::Hash;
6
7enum Foo {
8    Empty,
9    WithValue(u8),
10}
11
12fn do_nothing() {}
13
14fn main() {
15    let mut state = DefaultHasher::new();
16    let my_enum = Foo::Empty;
17
18    match my_enum {
19        Foo::Empty => 0_u8.hash(&mut state),
20        //~^ ERROR: this call to `hash` on the unit type will do nothing
21        //~| NOTE: the implementation of `Hash` for `()` is a no-op
22        Foo::WithValue(x) => x.hash(&mut state),
23    }
24
25    let res = ();
26    0_u8.hash(&mut state);
27    //~^ ERROR: this call to `hash` on the unit type will do nothing
28    //~| NOTE: the implementation of `Hash` for `()` is a no-op
29
30    #[allow(clippy::unit_arg)]
31    0_u8.hash(&mut state);
32    //~^ ERROR: this call to `hash` on the unit type will do nothing
33    //~| NOTE: the implementation of `Hash` for `()` is a no-op
34}