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/hir_def/src/test_db.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'crates/hir_def/src/test_db.rs') diff --git a/crates/hir_def/src/test_db.rs b/crates/hir_def/src/test_db.rs index 2b36c824a..00fe711fe 100644 --- a/crates/hir_def/src/test_db.rs +++ b/crates/hir_def/src/test_db.rs @@ -25,7 +25,7 @@ use crate::{db::DefDatabase, ModuleDefId}; crate::db::DefDatabaseStorage )] #[derive(Default)] -pub struct TestDB { +pub(crate) struct TestDB { storage: salsa::Storage, events: Mutex>>, } @@ -72,7 +72,7 @@ impl FileLoader for TestDB { } impl TestDB { - pub fn module_for_file(&self, file_id: FileId) -> crate::ModuleId { + pub(crate) fn module_for_file(&self, file_id: FileId) -> crate::ModuleId { for &krate in self.relevant_crates(file_id).iter() { let crate_def_map = self.crate_def_map(krate); for (local_id, data) in crate_def_map.modules.iter() { @@ -84,13 +84,13 @@ impl TestDB { panic!("Can't find module for file") } - pub fn log(&self, f: impl FnOnce()) -> Vec { + pub(crate) fn log(&self, f: impl FnOnce()) -> Vec { *self.events.lock().unwrap() = Some(Vec::new()); f(); self.events.lock().unwrap().take().unwrap() } - pub fn log_executed(&self, f: impl FnOnce()) -> Vec { + pub(crate) fn log_executed(&self, f: impl FnOnce()) -> Vec { let events = self.log(f); events .into_iter() @@ -105,7 +105,7 @@ impl TestDB { .collect() } - pub fn extract_annotations(&self) -> FxHashMap> { + pub(crate) fn extract_annotations(&self) -> FxHashMap> { let mut files = Vec::new(); let crate_graph = self.crate_graph(); for krate in crate_graph.iter() { @@ -129,7 +129,7 @@ impl TestDB { .collect() } - pub fn diagnostics(&self, mut cb: F) { + pub(crate) fn diagnostics(&self, mut cb: F) { let crate_graph = self.crate_graph(); for krate in crate_graph.iter() { let crate_def_map = self.crate_def_map(krate); @@ -148,7 +148,7 @@ impl TestDB { } } - pub fn check_diagnostics(&self) { + pub(crate) fn check_diagnostics(&self) { let db: &TestDB = self; let annotations = db.extract_annotations(); assert!(!annotations.is_empty()); -- cgit v1.2.3