|
| 1 | +use rustc_hir::def_id::LOCAL_CRATE; |
1 | 2 | use rustc_middle::ty::{self, ClosureSizeProfileData, Instance, TyCtxt}; |
2 | | -use std::fs::OpenOptions; |
3 | | -use std::io::prelude::*; |
4 | 3 |
|
5 | 4 | /// For a given closure, writes out the data for the profiling the impact of RFC 2229 on |
6 | 5 | /// closure size into a CSV. |
7 | 6 | /// |
8 | 7 | /// During the same compile all closures dump the information in the same file |
9 | 8 | /// "closure_profile_XXXXX.csv", which is created in the directory where the compiler is invoked. |
10 | 9 | crate fn dump_closure_profile(tcx: TyCtxt<'tcx>, closure_instance: Instance<'tcx>) { |
11 | | - let mut file = if let Ok(file) = OpenOptions::new() |
12 | | - .create(true) |
13 | | - .append(true) |
14 | | - .open(&format!("closure_profile_{}.csv", std::process::id())) |
15 | | - { |
16 | | - file |
17 | | - } else { |
18 | | - eprintln!("Cound't open file for writing closure profile"); |
19 | | - return; |
20 | | - }; |
21 | | - |
22 | 10 | let closure_def_id = closure_instance.def_id(); |
23 | 11 | let typeck_results = tcx.typeck(closure_def_id.expect_local()); |
24 | 12 |
|
| 13 | + let crate_name = tcx.crate_name(LOCAL_CRATE); |
| 14 | + |
25 | 15 | if typeck_results.closure_size_eval.contains_key(&closure_def_id) { |
26 | 16 | let param_env = ty::ParamEnv::reveal_all(); |
27 | 17 |
|
@@ -59,15 +49,13 @@ crate fn dump_closure_profile(tcx: TyCtxt<'tcx>, closure_instance: Instance<'tcx |
59 | 49 | .map(|l| format!("{:?} {:?}", l.lines.first(), l.lines.last())) |
60 | 50 | .unwrap_or_else(|e| format!("{:?}", e)); |
61 | 51 |
|
62 | | - if let Err(e) = writeln!( |
63 | | - file, |
64 | | - "{}, {}, {}, {:?}", |
| 52 | + eprintln!( |
| 53 | + "SG_CRATER_E239478slkdjf: {}, {}, {}, {}, {:?}", |
| 54 | + crate_name, |
65 | 55 | old_size, |
66 | 56 | new_size, |
67 | 57 | src_file.prefer_local(), |
68 | 58 | line_nos |
69 | | - ) { |
70 | | - eprintln!("Error writting to file {}", e.to_string()) |
71 | | - } |
| 59 | + ); |
72 | 60 | } |
73 | 61 | } |
0 commit comments