about summary refs log tree commit diff
path: root/compiler/rustc_codegen_ssa/src/debuginfo
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2022-06-14 17:19:38 +0000
committerbors <bors@rust-lang.org>2022-06-14 17:19:38 +0000
commit1f34da9ec8a85b6f86c5fa1c121ab6f88f2f4966 (patch)
tree26035c94f6942c918a3bac5708a1cd3071bbe5e9 /compiler/rustc_codegen_ssa/src/debuginfo
parent872503d918b2c3266d828f85e42951df74f5e303 (diff)
parent15c1c0652298e9dd3dee45813a2718623f6e3702 (diff)
downloadrust-1f34da9ec8a85b6f86c5fa1c121ab6f88f2f4966.tar.gz
rust-1f34da9ec8a85b6f86c5fa1c121ab6f88f2f4966.zip
Auto merge of #96591 - b-naber:transition-to-valtrees-in-type-system, r=lcnr
Use valtrees as the type-system representation for constant values

This is not quite ready yet, there are still some problems with pretty printing and symbol mangling and `deref_const` seems to not work correctly in all cases.

Mainly opening now for a perf-run (which should be good to go, despite the still existing problems).

r? `@oli-obk`

cc `@lcnr` `@RalfJung`
Diffstat (limited to 'compiler/rustc_codegen_ssa/src/debuginfo')
-rw-r--r--compiler/rustc_codegen_ssa/src/debuginfo/type_names.rs12
1 files changed, 8 insertions, 4 deletions
diff --git a/compiler/rustc_codegen_ssa/src/debuginfo/type_names.rs b/compiler/rustc_codegen_ssa/src/debuginfo/type_names.rs
index f8497702832..8755d91818d 100644
--- a/compiler/rustc_codegen_ssa/src/debuginfo/type_names.rs
+++ b/compiler/rustc_codegen_ssa/src/debuginfo/type_names.rs
@@ -703,15 +703,19 @@ fn push_const_param<'tcx>(tcx: TyCtxt<'tcx>, ct: ty::Const<'tcx>, output: &mut S
                 // but we get a deterministic, virtually unique value for the constant.
                 let hcx = &mut tcx.create_stable_hashing_context();
                 let mut hasher = StableHasher::new();
-                hcx.while_hashing_spans(false, |hcx| ct.kind().hash_stable(hcx, &mut hasher));
+                let ct = ct.eval(tcx, ty::ParamEnv::reveal_all());
+                hcx.while_hashing_spans(false, |hcx| ct.to_valtree().hash_stable(hcx, &mut hasher));
                 // Let's only emit 64 bits of the hash value. That should be plenty for
                 // avoiding collisions and will make the emitted type names shorter.
-                let hash: u64 = hasher.finish();
+                // Note: Don't use `StableHashResult` impl of `u64` here directly, since that
+                // would lead to endianness problems.
+                let hash: u128 = hasher.finish();
+                let hash_short = (hash.to_le() as u64).to_le();
 
                 if cpp_like_debuginfo(tcx) {
-                    write!(output, "CONST${:x}", hash)
+                    write!(output, "CONST${:x}", hash_short)
                 } else {
-                    write!(output, "{{CONST#{:x}}}", hash)
+                    write!(output, "{{CONST#{:x}}}", hash_short)
                 }
             }
         },