Skip to content

Commit 4351698

Browse files
Move duration_to_secs_str to rustc_session
1 parent 984c74a commit 4351698

File tree

3 files changed

+11
-9
lines changed

3 files changed

+11
-9
lines changed

src/librustc/util/common.rs

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -88,15 +88,7 @@ pub fn print_time_passes_entry(do_it: bool, what: &str, dur: Duration) {
8888
what);
8989
}
9090

91-
// Hack up our own formatting for the duration to make it easier for scripts
92-
// to parse (always use the same number of decimal places and the same unit).
93-
pub fn duration_to_secs_str(dur: Duration) -> String {
94-
const NANOS_PER_SEC: f64 = 1_000_000_000.0;
95-
let secs = dur.as_secs() as f64 +
96-
dur.subsec_nanos() as f64 / NANOS_PER_SEC;
97-
98-
format!("{:.3}", secs)
99-
}
91+
pub use rustc_session::utils::duration_to_secs_str;
10092

10193
pub fn to_readable_str(mut val: usize) -> String {
10294
let mut groups = vec![];

src/librustc_session/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
pub mod cgu_reuse_tracker;
2+
pub mod utils;

src/librustc_session/utils.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// Hack up our own formatting for the duration to make it easier for scripts
2+
// to parse (always use the same number of decimal places and the same unit).
3+
pub fn duration_to_secs_str(dur: std::time::Duration) -> String {
4+
const NANOS_PER_SEC: f64 = 1_000_000_000.0;
5+
let secs = dur.as_secs() as f64 +
6+
dur.subsec_nanos() as f64 / NANOS_PER_SEC;
7+
8+
format!("{:.3}", secs)
9+
}

0 commit comments

Comments
 (0)