1 #![allow(non_camel_case_types)]
3 use rustc_data_structures::sync::Lock;
6 use std::time::{Duration, Instant};
8 use rustc_span::symbol::{sym, Symbol};
13 // The name of the associated type for `Fn` return types.
14 pub const FN_OUTPUT_NAME: Symbol = sym::Output;
16 pub use errors::ErrorReported;
18 pub fn to_readable_str(mut val: usize) -> String {
19 let mut groups = vec![];
21 let group = val % 1000;
26 groups.push(group.to_string());
29 groups.push(format!("{:03}", group));
38 pub fn record_time<T, F>(accu: &Lock<Duration>, f: F) -> T
42 let start = Instant::now();
44 let duration = start.elapsed();
45 let mut accu = accu.lock();
46 *accu = *accu + duration;
50 pub fn indent<R, F>(op: F) -> R
55 // Use in conjunction with the log post-processor like `src/etc/indenter`
56 // to make debug output more readable.
59 debug!("<< (Result = {:?})", r);
64 _cannot_construct_outside_of_this_module: (),
67 impl Drop for Indenter {
73 pub fn indenter() -> Indenter {
75 Indenter { _cannot_construct_outside_of_this_module: () }