1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
|
#![feature(intrinsics)]
#[lang = "sized"]
trait Sized {}
pub mod core {
pub mod intrinsics {
#[lang = "discriminant_kind"]
pub trait DiscriminantKind {
#[lang = "discriminant_type"]
type Discriminant;
}
extern "rust-intrinsic" {
pub fn discriminant_value<T>(v: &T) -> <T as DiscriminantKind>::Discriminant;
}
}
pub mod hash {
pub trait Hasher {}
pub trait Hash {
/// Feeds this value into the given [`Hasher`].
///
/// # Examples
///
/// ```
/// use std::collections::hash_map::DefaultHasher;
/// use std::hash::{Hash, Hasher};
///
/// let mut hasher = DefaultHasher::new();
/// 7920.hash(&mut hasher);
/// println!("Hash is {:x}!", hasher.finish());
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
fn hash<H: Hasher>(&self, state: &mut H);
/// Feeds a slice of this type into the given [`Hasher`].
///
/// # Examples
///
/// ```
/// use std::collections::hash_map::DefaultHasher;
/// use std::hash::{Hash, Hasher};
///
/// let mut hasher = DefaultHasher::new();
/// let numbers = [6, 28, 496, 8128];
/// Hash::hash_slice(&numbers, &mut hasher);
/// println!("Hash is {:x}!", hasher.finish());
/// ```
#[stable(feature = "hash_slice", since = "1.3.0")]
fn hash_slice<H: Hasher>(data: &[Self], state: &mut H)
where
Self: Sized,
{
// for piece in data {
// piece.hash(state);
// }
}
}
}
}
impl core::hash::Hash for i32 {
fn hash<H: core::hash::Hasher>(&self, state: &mut H) {}
}
impl core::hash::Hash for i64 {
fn hash<H: core::hash::Hasher>(&self, state: &mut H) {}
}
// for the discriminant value
impl core::hash::Hash for isize {
fn hash<H: core::hash::Hasher>(&self, state: &mut H) {}
}
#[derive(Hash)]
struct Foo { // { dg-warning "never constructed" }
a: i32,
b: i32,
}
#[derive(Hash)]
struct Bar(i32, i64); // { dg-warning "never constructed" }
#[derive(Hash)]
enum Baz {
A,
B(i32),
C { a: i64 }
}
|