mirror of
https://github.com/salsa-rs/salsa.git
synced 2025-01-22 21:05:11 +00:00
Switch crate to pub(crate)
This commit is contained in:
parent
3b5f16cbcb
commit
1c349d4229
12 changed files with 25 additions and 30 deletions
|
@ -1,6 +1,5 @@
|
|||
#![deny(rust_2018_idioms)]
|
||||
#![feature(in_band_lifetimes)]
|
||||
#![feature(crate_visibility_modifier)]
|
||||
#![feature(nll)]
|
||||
#![feature(integer_atomics)]
|
||||
#![allow(dead_code)]
|
||||
|
|
|
@ -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<V>(
|
||||
pub(crate) fn execute_query_implementation<V>(
|
||||
&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<DB: Database> {
|
||||
pub(crate) enum QueryDescriptorSet<DB: Database> {
|
||||
/// All reads were to tracked things:
|
||||
Tracked(FxIndexSet<DB::QueryDescriptor>),
|
||||
|
||||
|
@ -285,7 +285,7 @@ impl<DB: Database> QueryDescriptorSet<DB> {
|
|||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
crate struct StampedValue<V> {
|
||||
crate value: V,
|
||||
crate changed_at: ChangedAt,
|
||||
pub(crate) struct StampedValue<V> {
|
||||
pub(crate) value: V,
|
||||
pub(crate) changed_at: ChangedAt,
|
||||
}
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
#![feature(crate_visibility_modifier)]
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct DatabaseImpl {
|
||||
runtime: salsa::Runtime<DatabaseImpl>,
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
use std::cell::Cell;
|
||||
|
||||
#[derive(Default)]
|
||||
crate struct Counter {
|
||||
pub(crate) struct Counter {
|
||||
value: Cell<usize>,
|
||||
}
|
||||
|
||||
impl Counter {
|
||||
crate fn increment(&self) -> usize {
|
||||
pub(crate) fn increment(&self) -> usize {
|
||||
let v = self.value.get();
|
||||
self.value.set(v + 1);
|
||||
v
|
||||
|
|
|
@ -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<TestContextImpl>,
|
||||
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;
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
use std::cell::RefCell;
|
||||
|
||||
#[derive(Default)]
|
||||
crate struct Log {
|
||||
pub(crate) struct Log {
|
||||
data: RefCell<Vec<String>>,
|
||||
}
|
||||
|
||||
impl Log {
|
||||
crate fn add(&self, text: impl Into<String>) {
|
||||
pub(crate) fn add(&self, text: impl Into<String>) {
|
||||
self.data.borrow_mut().push(text.into());
|
||||
}
|
||||
|
||||
crate fn take(&self) -> Vec<String> {
|
||||
pub(crate) fn take(&self) -> Vec<String> {
|
||||
std::mem::replace(&mut *self.data.borrow_mut(), vec![])
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
#![feature(crate_visibility_modifier)]
|
||||
#![feature(underscore_imports)]
|
||||
|
||||
mod counter;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
#![feature(crate_visibility_modifier)]
|
||||
#![feature(underscore_imports)]
|
||||
|
||||
mod implementation;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue