From 1c349d42297e295e22fb2255e4e390640c803052 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Tue, 9 Oct 2018 22:34:30 +0300 Subject: [PATCH] Switch crate to pub(crate) --- src/lib.rs | 1 - src/runtime.rs | 22 +++++++++++----------- tests/cycles.rs | 2 -- tests/incremental/counter.rs | 4 ++-- tests/incremental/implementation.rs | 8 ++++---- tests/incremental/log.rs | 6 +++--- tests/incremental/main.rs | 1 - tests/incremental/memoized_dep_inputs.rs | 2 +- tests/incremental/memoized_inputs.rs | 2 +- tests/incremental/memoized_volatile.rs | 2 +- tests/storage_varieties/main.rs | 1 - tests/storage_varieties/queries.rs | 4 ++-- 12 files changed, 25 insertions(+), 30 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index a5317cbf..4868c181 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,6 +1,5 @@ #![deny(rust_2018_idioms)] #![feature(in_band_lifetimes)] -#![feature(crate_visibility_modifier)] #![feature(nll)] #![feature(integer_atomics)] #![allow(dead_code)] diff --git a/src/runtime.rs b/src/runtime.rs index 604cec31..27f6005f 100644 --- a/src/runtime.rs +++ b/src/runtime.rs @@ -67,14 +67,14 @@ where } /// Read current value of the revision counter. - crate fn current_revision(&self) -> Revision { + pub(crate) fn current_revision(&self) -> Revision { Revision { generation: self.shared_state.revision.load(Ordering::SeqCst), } } /// Increments the current revision counter and returns the new value. - crate fn increment_revision(&self) -> Revision { + pub(crate) fn increment_revision(&self) -> Revision { if !self.local_state.borrow().query_stack.is_empty() { panic!("increment_revision invoked during a query computation"); } @@ -88,7 +88,7 @@ where result } - crate fn execute_query_implementation( + pub(crate) fn execute_query_implementation( &self, descriptor: &DB::QueryDescriptor, execute: impl FnOnce() -> V, @@ -132,13 +132,13 @@ where /// - `descriptor`: the query whose result was read /// - `changed_revision`: the last revision in which the result of that /// query had changed - crate fn report_query_read(&self, descriptor: &DB::QueryDescriptor, changed_at: ChangedAt) { + pub(crate) fn report_query_read(&self, descriptor: &DB::QueryDescriptor, changed_at: ChangedAt) { if let Some(top_query) = self.local_state.borrow_mut().query_stack.last_mut() { top_query.add_read(descriptor, changed_at); } } - crate fn report_untracked_read(&self) { + pub(crate) fn report_untracked_read(&self) { if let Some(top_query) = self.local_state.borrow_mut().query_stack.last_mut() { let changed_at = ChangedAt::Revision(self.current_revision()); top_query.add_untracked_read(changed_at); @@ -146,7 +146,7 @@ where } /// Obviously, this should be user configurable at some point. - crate fn report_unexpected_cycle(&self, descriptor: DB::QueryDescriptor) -> ! { + pub(crate) fn report_unexpected_cycle(&self, descriptor: DB::QueryDescriptor) -> ! { let local_state = self.local_state.borrow(); let LocalState { query_stack, .. } = &*local_state; @@ -213,7 +213,7 @@ pub struct Revision { } impl Revision { - crate const ZERO: Self = Revision { generation: 0 }; + pub(crate) const ZERO: Self = Revision { generation: 0 }; } impl std::fmt::Debug for Revision { @@ -243,7 +243,7 @@ impl ChangedAt { /// An insertion-order-preserving set of queries. Used to track the /// inputs accessed during query execution. -crate enum QueryDescriptorSet { +pub(crate) enum QueryDescriptorSet { /// All reads were to tracked things: Tracked(FxIndexSet), @@ -285,7 +285,7 @@ impl QueryDescriptorSet { } #[derive(Clone, Debug)] -crate struct StampedValue { - crate value: V, - crate changed_at: ChangedAt, +pub(crate) struct StampedValue { + pub(crate) value: V, + pub(crate) changed_at: ChangedAt, } diff --git a/tests/cycles.rs b/tests/cycles.rs index d608b8f2..4bc27c36 100644 --- a/tests/cycles.rs +++ b/tests/cycles.rs @@ -1,5 +1,3 @@ -#![feature(crate_visibility_modifier)] - #[derive(Default)] pub struct DatabaseImpl { runtime: salsa::Runtime, diff --git a/tests/incremental/counter.rs b/tests/incremental/counter.rs index f0d5fbb6..c04857e2 100644 --- a/tests/incremental/counter.rs +++ b/tests/incremental/counter.rs @@ -1,12 +1,12 @@ use std::cell::Cell; #[derive(Default)] -crate struct Counter { +pub(crate) struct Counter { value: Cell, } impl Counter { - crate fn increment(&self) -> usize { + pub(crate) fn increment(&self) -> usize { let v = self.value.get(); self.value.set(v + 1); v diff --git a/tests/incremental/implementation.rs b/tests/incremental/implementation.rs index 7d0231ae..868e49c9 100644 --- a/tests/incremental/implementation.rs +++ b/tests/incremental/implementation.rs @@ -4,20 +4,20 @@ use crate::memoized_dep_inputs; use crate::memoized_inputs; use crate::memoized_volatile; -crate trait TestContext: salsa::Database { +pub(crate) trait TestContext: salsa::Database { fn clock(&self) -> &Counter; fn log(&self) -> &Log; } #[derive(Default)] -crate struct TestContextImpl { +pub(crate) struct TestContextImpl { runtime: salsa::Runtime, clock: Counter, log: Log, } impl TestContextImpl { - crate fn assert_log(&self, expected_log: &[&str]) { + pub(crate) fn assert_log(&self, expected_log: &[&str]) { use difference::{Changeset, Difference}; let expected_text = &format!("{:#?}", expected_log); @@ -42,7 +42,7 @@ impl TestContextImpl { } salsa::database_storage! { - crate struct TestContextImplStorage for TestContextImpl { + pub(crate) struct TestContextImplStorage for TestContextImpl { impl memoized_dep_inputs::MemoizedDepInputsContext { fn dep_memoized2() for memoized_dep_inputs::Memoized2; fn dep_memoized1() for memoized_dep_inputs::Memoized1; diff --git a/tests/incremental/log.rs b/tests/incremental/log.rs index 469bd124..a27a60b2 100644 --- a/tests/incremental/log.rs +++ b/tests/incremental/log.rs @@ -1,16 +1,16 @@ use std::cell::RefCell; #[derive(Default)] -crate struct Log { +pub(crate) struct Log { data: RefCell>, } impl Log { - crate fn add(&self, text: impl Into) { + pub(crate) fn add(&self, text: impl Into) { self.data.borrow_mut().push(text.into()); } - crate fn take(&self) -> Vec { + pub(crate) fn take(&self) -> Vec { std::mem::replace(&mut *self.data.borrow_mut(), vec![]) } } diff --git a/tests/incremental/main.rs b/tests/incremental/main.rs index 8fe306be..f96565e3 100644 --- a/tests/incremental/main.rs +++ b/tests/incremental/main.rs @@ -1,4 +1,3 @@ -#![feature(crate_visibility_modifier)] #![feature(underscore_imports)] mod counter; diff --git a/tests/incremental/memoized_dep_inputs.rs b/tests/incremental/memoized_dep_inputs.rs index 489b158e..152ceb61 100644 --- a/tests/incremental/memoized_dep_inputs.rs +++ b/tests/incremental/memoized_dep_inputs.rs @@ -2,7 +2,7 @@ use crate::implementation::{TestContext, TestContextImpl}; use salsa::Database; salsa::query_group! { - crate trait MemoizedDepInputsContext: TestContext { + pub(crate) trait MemoizedDepInputsContext: TestContext { fn dep_memoized2(key: ()) -> usize { type Memoized2; } diff --git a/tests/incremental/memoized_inputs.rs b/tests/incremental/memoized_inputs.rs index 4ca268ef..0fdc9b79 100644 --- a/tests/incremental/memoized_inputs.rs +++ b/tests/incremental/memoized_inputs.rs @@ -2,7 +2,7 @@ use crate::implementation::{TestContext, TestContextImpl}; use salsa::Database; salsa::query_group! { - crate trait MemoizedInputsContext: TestContext { + pub(crate) trait MemoizedInputsContext: TestContext { fn max(key: ()) -> usize { type Max; } diff --git a/tests/incremental/memoized_volatile.rs b/tests/incremental/memoized_volatile.rs index 36bd3593..b01c2976 100644 --- a/tests/incremental/memoized_volatile.rs +++ b/tests/incremental/memoized_volatile.rs @@ -2,7 +2,7 @@ use crate::implementation::{TestContext, TestContextImpl}; use salsa::Database; salsa::query_group! { - crate trait MemoizedVolatileContext: TestContext { + pub(crate) trait MemoizedVolatileContext: TestContext { // Queries for testing a "volatile" value wrapped by // memoization. fn memoized2(key: ()) -> usize { diff --git a/tests/storage_varieties/main.rs b/tests/storage_varieties/main.rs index 0e90f20e..af0f9342 100644 --- a/tests/storage_varieties/main.rs +++ b/tests/storage_varieties/main.rs @@ -1,4 +1,3 @@ -#![feature(crate_visibility_modifier)] #![feature(underscore_imports)] mod implementation; diff --git a/tests/storage_varieties/queries.rs b/tests/storage_varieties/queries.rs index b66dc53e..763e48ab 100644 --- a/tests/storage_varieties/queries.rs +++ b/tests/storage_varieties/queries.rs @@ -1,9 +1,9 @@ -crate trait Counter: salsa::Database { +pub(crate) trait Counter: salsa::Database { fn increment(&self) -> usize; } salsa::query_group! { - crate trait Database: Counter { + pub(crate) trait Database: Counter { fn memoized(key: ()) -> usize { type Memoized; }