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