Skip to content

Commit a93bb8d

Browse files
committed
Add get_type_sizes to CodeStats
1 parent 9ffde4b commit a93bb8d

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

compiler/rustc_session/src/code_stats.rs

+9-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1+
12
use std::cmp;
23

34
use rustc_abi::{Align, Size};
45
use rustc_data_structures::fx::FxHashSet;
5-
use rustc_data_structures::sync::Lock;
6+
use rustc_data_structures::sync::{Lock, LockGuard};
67
use rustc_span::Symbol;
78

89
#[derive(Clone, PartialEq, Eq, Hash, Debug)]
@@ -106,6 +107,13 @@ impl CodeStats {
106107
self.type_sizes.borrow_mut().insert(info);
107108
}
108109

110+
/// Get type sizes if possible, returns `None` if internal lock is locked,
111+
/// or couldn't be locked
112+
#[inline]
113+
pub fn get_type_sizes(&self) -> Option<LockGuard<'_, FxHashSet<TypeSizeInfo>>> {
114+
self.type_sizes.try_lock()
115+
}
116+
109117
pub fn print_type_sizes(&self) {
110118
let type_sizes = self.type_sizes.borrow();
111119
// We will soon sort, so the initial order does not matter.

0 commit comments

Comments
 (0)