rustc_codegen_llvm/
value.rs

1use std::hash::{Hash, Hasher};
2use std::{fmt, ptr};
3
4use crate::llvm::{self, Value};
5
6impl PartialEq for Value {
7    fn eq(&self, other: &Self) -> bool {
8        ptr::eq(self, other)
9    }
10}
11
12impl Eq for Value {}
13
14impl Hash for Value {
15    fn hash<H: Hasher>(&self, hasher: &mut H) {
16        (self as *const Self).hash(hasher);
17    }
18}
19
20impl fmt::Debug for Value {
21    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
22        f.write_str(
23            &llvm::build_string(|s| unsafe {
24                llvm::LLVMRustWriteValueToString(self, s);
25            })
26            .expect("non-UTF8 value description from LLVM"),
27        )
28    }
29}