From b6101184537b1165cfdd5fc473e04ad4c5b7bffa Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Mon, 2 Nov 2020 13:13:32 +0100 Subject: 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. --- crates/profile/src/hprof.rs | 4 ++-- crates/profile/src/tree.rs | 16 ++++++++-------- 2 files changed, 10 insertions(+), 10 deletions(-) (limited to 'crates/profile') 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) { filter.install(); } -pub type Label = &'static str; +type Label = &'static str; /// This function starts a profiling scope in the current execution stack with a given description. /// It returns a `Profile` struct that measures elapsed time between this method invocation and `Profile` struct drop. @@ -173,7 +173,7 @@ impl ProfileStack { true } - pub fn pop(&mut self, label: Label, detail: Option) { + fn pop(&mut self, label: Label, detail: Option) { let start = self.starts.pop().unwrap(); let duration = start.elapsed(); 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; use arena::Arena; #[derive(Default)] -pub struct Tree { +pub(crate) struct Tree { nodes: Arena>, current_path: Vec<(Idx, Option>)>, } -pub type Idx = arena::Idx>; +pub(crate) type Idx = arena::Idx>; impl Tree { - pub fn start(&mut self) + pub(crate) fn start(&mut self) where T: Default, { @@ -30,19 +30,19 @@ impl Tree { self.current_path.push((me, None)); } - pub fn finish(&mut self, data: T) { + pub(crate) fn finish(&mut self, data: T) { let (me, _last_child) = self.current_path.pop().unwrap(); self.nodes[me].data = data; } - pub fn root(&self) -> Option> { + pub(crate) fn root(&self) -> Option> { self.nodes.iter().next().map(|(idx, _)| idx) } - pub fn children(&self, idx: Idx) -> impl Iterator> + '_ { + pub(crate) fn children(&self, idx: Idx) -> impl Iterator> + '_ { NodeIter { nodes: &self.nodes, next: self.nodes[idx].first_child } } - pub fn clear(&mut self) { + pub(crate) fn clear(&mut self) { self.nodes.clear(); self.current_path.clear(); } @@ -55,7 +55,7 @@ impl ops::Index> for Tree { } } -pub struct Node { +pub(crate) struct Node { data: T, first_child: Option>, next_sibling: Option>, -- cgit v1.2.3