Skip to content

Commit 3f2a880

Browse files
committed
Add get_type_sizes to CodeStats
1 parent 40dacd5 commit 3f2a880

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

Diff for: compiler/rustc_session/src/code_stats.rs

+8-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use std::cmp;
22

33
use rustc_abi::{Align, Size};
44
use rustc_data_structures::fx::FxHashSet;
5-
use rustc_data_structures::sync::Lock;
5+
use rustc_data_structures::sync::{Lock, LockGuard};
66
use rustc_span::Symbol;
77

88
#[derive(Clone, PartialEq, Eq, Hash, Debug)]
@@ -106,6 +106,13 @@ impl CodeStats {
106106
self.type_sizes.borrow_mut().insert(info);
107107
}
108108

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

0 commit comments

Comments
 (0)