aboutsummaryrefslogtreecommitdiff
path: root/crates/profile
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2020-11-02 12:13:32 +0000
committerAleksey Kladov <[email protected]>2020-11-02 13:07:08 +0000
commitb6101184537b1165cfdd5fc473e04ad4c5b7bffa (patch)
treebcc2efd8a2696840a4724ad88758e973ecb77157 /crates/profile
parente7f90866bcf4b04a11e958eda0ac53f7ff0a607b (diff)
Deny unreachable-pub
It's very useful when `pub` is equivalent to "this is crate's public API", let's enforce this! Ideally, we should enforce it for local `cargo test`, and only during CI, but that needs https://github.com/rust-lang/cargo/issues/5034.
Diffstat (limited to 'crates/profile')
-rw-r--r--crates/profile/src/hprof.rs4
-rw-r--r--crates/profile/src/tree.rs16
2 files changed, 10 insertions, 10 deletions
diff --git a/crates/profile/src/hprof.rs b/crates/profile/src/hprof.rs
index 934cc8e37..8957ea016 100644
--- a/crates/profile/src/hprof.rs
+++ b/crates/profile/src/hprof.rs
@@ -27,7 +27,7 @@ pub fn init_from(spec: &str) {
27 filter.install(); 27 filter.install();
28} 28}
29 29
30pub type Label = &'static str; 30type Label = &'static str;
31 31
32/// This function starts a profiling scope in the current execution stack with a given description. 32/// This function starts a profiling scope in the current execution stack with a given description.
33/// It returns a `Profile` struct that measures elapsed time between this method invocation and `Profile` struct drop. 33/// It returns a `Profile` struct that measures elapsed time between this method invocation and `Profile` struct drop.
@@ -173,7 +173,7 @@ impl ProfileStack {
173 true 173 true
174 } 174 }
175 175
176 pub fn pop(&mut self, label: Label, detail: Option<String>) { 176 fn pop(&mut self, label: Label, detail: Option<String>) {
177 let start = self.starts.pop().unwrap(); 177 let start = self.starts.pop().unwrap();
178 let duration = start.elapsed(); 178 let duration = start.elapsed();
179 self.messages.finish(Message { duration, label, detail }); 179 self.messages.finish(Message { duration, label, detail });
diff --git a/crates/profile/src/tree.rs b/crates/profile/src/tree.rs
index 096f58511..3fac1f36c 100644
--- a/crates/profile/src/tree.rs
+++ b/crates/profile/src/tree.rs
@@ -4,15 +4,15 @@ use std::ops;
4use arena::Arena; 4use arena::Arena;
5 5
6#[derive(Default)] 6#[derive(Default)]
7pub struct Tree<T> { 7pub(crate) struct Tree<T> {
8 nodes: Arena<Node<T>>, 8 nodes: Arena<Node<T>>,
9 current_path: Vec<(Idx<T>, Option<Idx<T>>)>, 9 current_path: Vec<(Idx<T>, Option<Idx<T>>)>,
10} 10}
11 11
12pub type Idx<T> = arena::Idx<Node<T>>; 12pub(crate) type Idx<T> = arena::Idx<Node<T>>;
13 13
14impl<T> Tree<T> { 14impl<T> Tree<T> {
15 pub fn start(&mut self) 15 pub(crate) fn start(&mut self)
16 where 16 where
17 T: Default, 17 T: Default,
18 { 18 {
@@ -30,19 +30,19 @@ impl<T> Tree<T> {
30 self.current_path.push((me, None)); 30 self.current_path.push((me, None));
31 } 31 }
32 32
33 pub fn finish(&mut self, data: T) { 33 pub(crate) fn finish(&mut self, data: T) {
34 let (me, _last_child) = self.current_path.pop().unwrap(); 34 let (me, _last_child) = self.current_path.pop().unwrap();
35 self.nodes[me].data = data; 35 self.nodes[me].data = data;
36 } 36 }
37 37
38 pub fn root(&self) -> Option<Idx<T>> { 38 pub(crate) fn root(&self) -> Option<Idx<T>> {
39 self.nodes.iter().next().map(|(idx, _)| idx) 39 self.nodes.iter().next().map(|(idx, _)| idx)
40 } 40 }
41 41
42 pub fn children(&self, idx: Idx<T>) -> impl Iterator<Item = Idx<T>> + '_ { 42 pub(crate) fn children(&self, idx: Idx<T>) -> impl Iterator<Item = Idx<T>> + '_ {
43 NodeIter { nodes: &self.nodes, next: self.nodes[idx].first_child } 43 NodeIter { nodes: &self.nodes, next: self.nodes[idx].first_child }
44 } 44 }
45 pub fn clear(&mut self) { 45 pub(crate) fn clear(&mut self) {
46 self.nodes.clear(); 46 self.nodes.clear();
47 self.current_path.clear(); 47 self.current_path.clear();
48 } 48 }
@@ -55,7 +55,7 @@ impl<T> ops::Index<Idx<T>> for Tree<T> {
55 } 55 }
56} 56}
57 57
58pub struct Node<T> { 58pub(crate) struct Node<T> {
59 data: T, 59 data: T,
60 first_child: Option<Idx<T>>, 60 first_child: Option<Idx<T>>,
61 next_sibling: Option<Idx<T>>, 61 next_sibling: Option<Idx<T>>,