|
| 1 | +use rustc_data_structures::stable_hasher::{HashStable, StableHasher}; |
1 | 2 | use rustc_hir::def_id::LOCAL_CRATE;
|
2 | 3 | use rustc_middle::ty::{self, ClosureSizeProfileData, Instance, TyCtxt};
|
3 | 4 |
|
@@ -39,23 +40,10 @@ crate fn dump_closure_profile(tcx: TyCtxt<'tcx>, closure_instance: Instance<'tcx
|
39 | 40 | .map(|l| format!("{:?}", l.size.bytes()))
|
40 | 41 | .unwrap_or_else(|e| format!("Failed {:?}", e));
|
41 | 42 |
|
42 |
| - let closure_hir_id = tcx.hir().local_def_id_to_hir_id(closure_def_id.expect_local()); |
43 |
| - let closure_span = tcx.hir().span(closure_hir_id); |
44 |
| - let src_file = tcx.sess.source_map().span_to_filename(closure_span); |
45 |
| - let line_nos = tcx |
46 |
| - .sess |
47 |
| - .source_map() |
48 |
| - .span_to_lines(closure_span) |
49 |
| - .map(|l| format!("{:?} {:?}", l.lines.first(), l.lines.last())) |
50 |
| - .unwrap_or_else(|e| format!("{:?}", e)); |
51 |
| - |
52 |
| - eprintln!( |
53 |
| - "SG_CRATER_E239478slkdjf: {}, {}, {}, {}, {:?}", |
54 |
| - crate_name, |
55 |
| - old_size, |
56 |
| - new_size, |
57 |
| - src_file.prefer_local(), |
58 |
| - line_nos |
59 |
| - ); |
| 43 | + let mut hasher = StableHasher::new(); |
| 44 | + closure_instance.hash_stable(&mut tcx.create_stable_hashing_context(), &mut hasher); |
| 45 | + let hash = hasher.finalize(); |
| 46 | + |
| 47 | + eprintln!("SG_CR_Eslkdjf: {}, {:x?}, {}, {}", crate_name, hash, old_size, new_size); |
60 | 48 | }
|
61 | 49 | }
|
0 commit comments