Skip to content

Commit 7709045

Browse files
committed
chore(turbo-tasks-backend): Remove ExecuteContextImpl::lower_read_transaction
1 parent 81c4881 commit 7709045

File tree

10 files changed

+11
-68
lines changed

10 files changed

+11
-68
lines changed

turbopack/crates/turbo-tasks-backend/src/backend/operation/mod.rs

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -107,10 +107,11 @@ where
107107
}
108108
}
109109

110-
fn transaction<'l>(&'l mut self) -> Option<&'l B::ReadTransaction<'l>>
111-
where
112-
'e: 'l,
113-
{
110+
fn restore_task_data(
111+
&mut self,
112+
task_id: TaskId,
113+
category: TaskDataCategory,
114+
) -> Vec<CachedDataItem> {
114115
if matches!(self.transaction, TransactionState::None) {
115116
let tx = self.backend.backing_storage.start_read_transaction();
116117
let tx = tx.map(|tx| {
@@ -119,23 +120,16 @@ where
119120
});
120121
self.transaction = TransactionState::Owned(tx);
121122
}
122-
match &self.transaction {
123+
let tx = match &self.transaction {
123124
TransactionState::None => unreachable!(),
124-
TransactionState::Borrowed(tx) => tx.map(B::lower_read_transaction),
125-
TransactionState::Owned(tx) => tx.as_ref().map(B::lower_read_transaction),
126-
}
127-
}
128-
129-
fn restore_task_data(
130-
&mut self,
131-
task_id: TaskId,
132-
category: TaskDataCategory,
133-
) -> Vec<CachedDataItem> {
134-
// Safety: `transaction` is a valid transaction from `self.backend.backing_storage`.
125+
TransactionState::Borrowed(tx) => *tx,
126+
TransactionState::Owned(tx) => tx.as_ref(),
127+
};
128+
// Safety: `tx` is a valid transaction from `self.backend.backing_storage`.
135129
let result = unsafe {
136130
self.backend
137131
.backing_storage
138-
.lookup_data(self.transaction(), task_id, category)
132+
.lookup_data(tx, task_id, category)
139133
};
140134
match result {
141135
Ok(data) => data,

turbopack/crates/turbo-tasks-backend/src/backing_storage.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,6 @@ pub trait BackingStorage: BackingStorageSealed {
4141
/// [`BackingStorage::invalidate`] method.
4242
pub trait BackingStorageSealed: 'static + Send + Sync {
4343
type ReadTransaction<'l>;
44-
fn lower_read_transaction<'l: 'i + 'r, 'i: 'r, 'r>(
45-
tx: &'r Self::ReadTransaction<'l>,
46-
) -> &'r Self::ReadTransaction<'i>;
4744
fn next_free_task_id(&self) -> Result<TaskId>;
4845
fn next_session_id(&self) -> Result<SessionId>;
4946
fn uncompleted_operations(&self) -> Result<Vec<AnyOperation>>;

turbopack/crates/turbo-tasks-backend/src/database/fresh_db_optimization.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,6 @@ impl<T: KeyValueDatabase> KeyValueDatabase for FreshDbOptimization<T> {
3737
where
3838
Self: 'l;
3939

40-
fn lower_read_transaction<'l: 'i + 'r, 'i: 'r, 'r>(
41-
tx: &'r Self::ReadTransaction<'l>,
42-
) -> &'r Self::ReadTransaction<'i> {
43-
T::lower_read_transaction(tx)
44-
}
45-
4640
fn is_empty(&self) -> bool {
4741
self.fresh_db.load(Ordering::Acquire) || self.database.is_empty()
4842
}

turbopack/crates/turbo-tasks-backend/src/database/key_value_database.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,6 @@ pub trait KeyValueDatabase {
1818
where
1919
Self: 'l;
2020

21-
fn lower_read_transaction<'l: 'i + 'r, 'i: 'r, 'r>(
22-
tx: &'r Self::ReadTransaction<'l>,
23-
) -> &'r Self::ReadTransaction<'i>;
24-
2521
fn begin_read_transaction(&self) -> Result<Self::ReadTransaction<'_>>;
2622

2723
fn is_empty(&self) -> bool {

turbopack/crates/turbo-tasks-backend/src/database/lmdb/mod.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -75,12 +75,6 @@ impl KeyValueDatabase for LmbdKeyValueDatabase {
7575
where
7676
Self: 'l;
7777

78-
fn lower_read_transaction<'l: 'i + 'r, 'i: 'r, 'r>(
79-
tx: &'r Self::ReadTransaction<'l>,
80-
) -> &'r Self::ReadTransaction<'i> {
81-
tx
82-
}
83-
8478
fn begin_read_transaction(&self) -> Result<Self::ReadTransaction<'_>> {
8579
Ok(self.env.begin_ro_txn()?)
8680
}

turbopack/crates/turbo-tasks-backend/src/database/noop_kv.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,6 @@ impl KeyValueDatabase for NoopKvDb {
1515
where
1616
Self: 'l;
1717

18-
fn lower_read_transaction<'l: 'i + 'r, 'i: 'r, 'r>(
19-
tx: &'r Self::ReadTransaction<'l>,
20-
) -> &'r Self::ReadTransaction<'i> {
21-
tx
22-
}
23-
2418
fn begin_read_transaction(&self) -> Result<Self::ReadTransaction<'_>> {
2519
Ok(())
2620
}

turbopack/crates/turbo-tasks-backend/src/database/read_transaction_cache.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -53,14 +53,6 @@ impl<T: KeyValueDatabase + 'static> KeyValueDatabase for ReadTransactionCache<T>
5353
where
5454
T: 'l;
5555

56-
fn lower_read_transaction<'l: 'i + 'r, 'i: 'r, 'r>(
57-
tx: &'r Self::ReadTransaction<'l>,
58-
) -> &'r Self::ReadTransaction<'i> {
59-
// Safety: When T compiles fine and lower_read_transaction is implemented correctly this is
60-
// safe to do.
61-
unsafe { transmute::<&'r Self::ReadTransaction<'l>, &'r Self::ReadTransaction<'i>>(tx) }
62-
}
63-
6456
fn is_empty(&self) -> bool {
6557
self.database.is_empty()
6658
}

turbopack/crates/turbo-tasks-backend/src/database/startup_cache.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -105,12 +105,6 @@ impl<T: KeyValueDatabase> KeyValueDatabase for StartupCacheLayer<T> {
105105
where
106106
Self: 'l;
107107

108-
fn lower_read_transaction<'l: 'i + 'r, 'i: 'r, 'r>(
109-
tx: &'r Self::ReadTransaction<'l>,
110-
) -> &'r Self::ReadTransaction<'i> {
111-
T::lower_read_transaction(tx)
112-
}
113-
114108
fn is_empty(&self) -> bool {
115109
self.database.is_empty()
116110
}

turbopack/crates/turbo-tasks-backend/src/database/turbo.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,6 @@ impl KeyValueDatabase for TurboKeyValueDatabase {
5050
where
5151
Self: 'l;
5252

53-
fn lower_read_transaction<'l: 'i + 'r, 'i: 'r, 'r>(
54-
tx: &'r Self::ReadTransaction<'l>,
55-
) -> &'r Self::ReadTransaction<'i> {
56-
tx
57-
}
58-
5953
fn is_empty(&self) -> bool {
6054
self.db.is_empty()
6155
}

turbopack/crates/turbo-tasks-backend/src/kv_backing_storage.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -262,12 +262,6 @@ impl<T: KeyValueDatabase + Send + Sync + 'static> BackingStorageSealed
262262
{
263263
type ReadTransaction<'l> = T::ReadTransaction<'l>;
264264

265-
fn lower_read_transaction<'l: 'i + 'r, 'i: 'r, 'r>(
266-
tx: &'r Self::ReadTransaction<'l>,
267-
) -> &'r Self::ReadTransaction<'i> {
268-
T::lower_read_transaction(tx)
269-
}
270-
271265
fn next_free_task_id(&self) -> Result<TaskId> {
272266
Ok(TaskId::try_from(
273267
self.inner

0 commit comments

Comments
 (0)