Skip to content

Commit 0a6197d

Browse files
committed
rustfmt
1 parent 159a03a commit 0a6197d

21 files changed

+128
-365
lines changed

crates/salsa/src/derived.rs

Lines changed: 9 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,7 @@ where
108108
query_index: Q::QUERY_INDEX,
109109
key_index,
110110
};
111-
entry
112-
.or_insert_with(|| Arc::new(Slot::new(key.clone(), database_key_index)))
113-
.clone()
111+
entry.or_insert_with(|| Arc::new(Slot::new(key.clone(), database_key_index))).clone()
114112
}
115113
}
116114

@@ -152,36 +150,25 @@ where
152150
assert_eq!(input.group_index, self.group_index);
153151
assert_eq!(input.query_index, Q::QUERY_INDEX);
154152
debug_assert!(revision < db.salsa_runtime().current_revision());
155-
let slot = self
156-
.slot_map
157-
.read()
158-
.get_index(input.key_index as usize)
159-
.unwrap()
160-
.1
161-
.clone();
153+
let slot = self.slot_map.read().get_index(input.key_index as usize).unwrap().1.clone();
162154
slot.maybe_changed_after(db, revision)
163155
}
164156

165157
fn fetch(&self, db: &<Q as QueryDb<'_>>::DynDb, key: &Q::Key) -> Q::Value {
166158
db.unwind_if_cancelled();
167159

168160
let slot = self.slot(key);
169-
let StampedValue {
170-
value,
171-
durability,
172-
changed_at,
173-
} = slot.read(db);
161+
let StampedValue { value, durability, changed_at } = slot.read(db);
174162

175163
if let Some(evicted) = self.lru_list.record_use(&slot) {
176164
evicted.evict();
177165
}
178166

179-
db.salsa_runtime()
180-
.report_query_read_and_unwind_if_cycle_resulted(
181-
slot.database_key_index(),
182-
durability,
183-
changed_at,
184-
);
167+
db.salsa_runtime().report_query_read_and_unwind_if_cycle_resulted(
168+
slot.database_key_index(),
169+
durability,
170+
changed_at,
171+
);
185172

186173
value
187174
}
@@ -195,10 +182,7 @@ where
195182
C: std::iter::FromIterator<TableEntry<Q::Key, Q::Value>>,
196183
{
197184
let slot_map = self.slot_map.read();
198-
slot_map
199-
.values()
200-
.filter_map(|slot| slot.as_table_entry())
201-
.collect()
185+
slot_map.values().filter_map(|slot| slot.as_table_entry()).collect()
202186
}
203187
}
204188

crates/salsa/src/derived/slot.rs

Lines changed: 17 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -209,14 +209,7 @@ where
209209
}
210210
}
211211

212-
self.execute(
213-
db,
214-
runtime,
215-
revision_now,
216-
active_query,
217-
panic_guard,
218-
old_memo,
219-
)
212+
self.execute(db, runtime, revision_now, active_query, panic_guard, old_memo)
220213
}
221214

222215
fn execute(
@@ -232,9 +225,7 @@ where
232225

233226
db.salsa_event(Event {
234227
runtime_id: db.salsa_runtime().id(),
235-
kind: EventKind::WillExecute {
236-
database_key: self.database_key_index,
237-
},
228+
kind: EventKind::WillExecute { database_key: self.database_key_index },
238229
});
239230

240231
// Query was not previously executed, or value is potentially
@@ -310,22 +301,12 @@ where
310301
changed_at: revisions.changed_at,
311302
};
312303

313-
let memo_value = if self.should_memoize_value(&self.key) {
314-
Some(new_value.value.clone())
315-
} else {
316-
None
317-
};
304+
let memo_value =
305+
if self.should_memoize_value(&self.key) { Some(new_value.value.clone()) } else { None };
318306

319-
debug!(
320-
"read_upgrade({:?}): result.revisions = {:#?}",
321-
self, revisions,
322-
);
307+
debug!("read_upgrade({:?}): result.revisions = {:#?}", self, revisions,);
323308

324-
panic_guard.proceed(Some(Memo {
325-
value: memo_value,
326-
verified_at: revision_now,
327-
revisions,
328-
}));
309+
panic_guard.proceed(Some(Memo { value: memo_value, verified_at: revision_now, revisions }));
329310

330311
new_value
331312
}
@@ -388,10 +369,7 @@ where
388369
value: value.clone(),
389370
};
390371

391-
info!(
392-
"{:?}: returning memoized value changed at {:?}",
393-
self, value.changed_at
394-
);
372+
info!("{:?}: returning memoized value changed at {:?}", self, value.changed_at);
395373

396374
ProbeState::UpToDate(value)
397375
} else {
@@ -503,11 +481,9 @@ where
503481
// If we know when value last changed, we can return right away.
504482
// Note that we don't need the actual value to be available.
505483
ProbeState::NoValue(_, changed_at)
506-
| ProbeState::UpToDate(StampedValue {
507-
value: _,
508-
durability: _,
509-
changed_at,
510-
}) => MaybeChangedSinceProbeState::ChangedAt(changed_at),
484+
| ProbeState::UpToDate(StampedValue { value: _, durability: _, changed_at }) => {
485+
MaybeChangedSinceProbeState::ChangedAt(changed_at)
486+
}
511487

512488
// If we have nothing cached, then value may have changed.
513489
ProbeState::NotComputed(_) => MaybeChangedSinceProbeState::ChangedAt(revision_now),
@@ -561,14 +537,8 @@ where
561537
// We found that this memoized value may have changed
562538
// but we have an old value. We can re-run the code and
563539
// actually *check* if it has changed.
564-
let StampedValue { changed_at, .. } = self.execute(
565-
db,
566-
runtime,
567-
revision_now,
568-
active_query,
569-
panic_guard,
570-
Some(old_memo),
571-
);
540+
let StampedValue { changed_at, .. } =
541+
self.execute(db, runtime, revision_now, active_query, panic_guard, Some(old_memo));
572542
changed_at > revision
573543
} else {
574544
// We found that inputs to this memoized value may have chanced
@@ -605,10 +575,7 @@ where
605575
Q: QueryFunction,
606576
{
607577
fn in_progress(id: RuntimeId) -> Self {
608-
QueryState::InProgress {
609-
id,
610-
anyone_waiting: Default::default(),
611-
}
578+
QueryState::InProgress { id, anyone_waiting: Default::default() }
612579
}
613580
}
614581

@@ -632,11 +599,7 @@ where
632599
slot: &'me Slot<Q, MP>,
633600
runtime: &'me Runtime,
634601
) -> Self {
635-
Self {
636-
database_key_index,
637-
slot,
638-
runtime,
639-
}
602+
Self { database_key_index, slot, runtime }
640603
}
641604

642605
/// Indicates that we have concluded normally (without panicking).
@@ -674,8 +637,7 @@ where
674637
// acquire a mutex; the mutex will guarantee that all writes
675638
// we are interested in are visible.
676639
if anyone_waiting.load(Ordering::Relaxed) {
677-
self.runtime
678-
.unblock_queries_blocked_on(self.database_key_index, wait_result);
640+
self.runtime.unblock_queries_blocked_on(self.database_key_index, wait_result);
679641
}
680642
}
681643
_ => panic!(
@@ -784,9 +746,8 @@ where
784746
// are only interested in finding out whether the
785747
// input changed *again*.
786748
QueryInputs::Tracked { inputs } => {
787-
let changed_input = inputs
788-
.iter()
789-
.find(|&&input| db.maybe_changed_after(input, verified_at));
749+
let changed_input =
750+
inputs.iter().find(|&&input| db.maybe_changed_after(input, verified_at));
790751
if let Some(input) = changed_input {
791752
debug!("validate_memoized_value: `{:?}` may have changed", input);
792753

crates/salsa/src/input.rs

Lines changed: 9 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,7 @@ where
5050
const CYCLE_STRATEGY: crate::plumbing::CycleRecoveryStrategy = CycleRecoveryStrategy::Panic;
5151

5252
fn new(group_index: u16) -> Self {
53-
InputStorage {
54-
group_index,
55-
slots: Default::default(),
56-
}
53+
InputStorage { group_index, slots: Default::default() }
5754
}
5855

5956
fn fmt_index(
@@ -91,18 +88,13 @@ where
9188
.get(key)
9289
.unwrap_or_else(|| panic!("no value set for {:?}({:?})", Q::default(), key));
9390

94-
let StampedValue {
95-
value,
91+
let StampedValue { value, durability, changed_at } = slot.stamped_value.read().clone();
92+
93+
db.salsa_runtime().report_query_read_and_unwind_if_cycle_resulted(
94+
slot.database_key_index,
9695
durability,
9796
changed_at,
98-
} = slot.stamped_value.read().clone();
99-
100-
db.salsa_runtime()
101-
.report_query_read_and_unwind_if_cycle_resulted(
102-
slot.database_key_index,
103-
durability,
104-
changed_at,
105-
);
97+
);
10698

10799
value
108100
}
@@ -133,10 +125,7 @@ where
133125
Q: Query,
134126
{
135127
fn maybe_changed_after(&self, _db: &<Q as QueryDb<'_>>::DynDb, revision: Revision) -> bool {
136-
debug!(
137-
"maybe_changed_after(slot={:?}, revision={:?})",
138-
self, revision,
139-
);
128+
debug!("maybe_changed_after(slot={:?}, revision={:?})", self, revision,);
140129

141130
let changed_at = self.stamped_value.read().changed_at;
142131

@@ -160,13 +149,7 @@ where
160149
Q: Query,
161150
{
162151
fn set(&self, runtime: &mut Runtime, key: &Q::Key, value: Q::Value, durability: Durability) {
163-
tracing::debug!(
164-
"{:?}({:?}) = {:?} ({:?})",
165-
Q::default(),
166-
key,
167-
value,
168-
durability
169-
);
152+
tracing::debug!("{:?}({:?}) = {:?} ({:?})", Q::default(), key, value, durability);
170153

171154
// The value is changing, so we need a new revision (*). We also
172155
// need to update the 'last changed' revision by invoking
@@ -190,11 +173,7 @@ where
190173
// racing with somebody else to modify this same cell.
191174
// (Otherwise, someone else might write a *newer* revision
192175
// into the same cell while we block on the lock.)
193-
let stamped_value = StampedValue {
194-
value,
195-
durability,
196-
changed_at: next_revision,
197-
};
176+
let stamped_value = StampedValue { value, durability, changed_at: next_revision };
198177

199178
match slots.entry(key.clone()) {
200179
Entry::Occupied(entry) => {

crates/salsa/src/intern_id.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,7 @@ impl InternId {
6363
/// `value` must be less than `MAX`
6464
pub const unsafe fn new_unchecked(value: u32) -> Self {
6565
debug_assert!(value < InternId::MAX);
66-
InternId {
67-
value: NonZeroU32::new_unchecked(value + 1),
68-
}
66+
InternId { value: NonZeroU32::new_unchecked(value + 1) }
6967
}
7068

7169
/// Convert this raw-id into a u32 value.

crates/salsa/src/interned.rs

Lines changed: 14 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -110,10 +110,7 @@ where
110110
K: Eq + Hash,
111111
{
112112
fn default() -> Self {
113-
Self {
114-
map: Default::default(),
115-
values: Default::default(),
116-
}
113+
Self { map: Default::default(), values: Default::default() }
117114
}
118115
}
119116

@@ -159,11 +156,7 @@ where
159156
query_index: Q::QUERY_INDEX,
160157
key_index: index.as_u32(),
161158
};
162-
Arc::new(Slot {
163-
database_key_index,
164-
value: owned_key2,
165-
interned_at: revision_now,
166-
})
159+
Arc::new(Slot { database_key_index, value: owned_key2, interned_at: revision_now })
167160
};
168161

169162
let (slot, index);
@@ -194,10 +187,7 @@ where
194187
const CYCLE_STRATEGY: crate::plumbing::CycleRecoveryStrategy = CycleRecoveryStrategy::Panic;
195188

196189
fn new(group_index: u16) -> Self {
197-
InternedStorage {
198-
group_index,
199-
tables: RwLock::new(InternTables::default()),
200-
}
190+
InternedStorage { group_index, tables: RwLock::new(InternTables::default()) }
201191
}
202192

203193
fn fmt_index(
@@ -231,12 +221,11 @@ where
231221
db.unwind_if_cancelled();
232222
let (slot, index) = self.intern_index(db, key);
233223
let changed_at = slot.interned_at;
234-
db.salsa_runtime()
235-
.report_query_read_and_unwind_if_cycle_resulted(
236-
slot.database_key_index,
237-
INTERN_DURABILITY,
238-
changed_at,
239-
);
224+
db.salsa_runtime().report_query_read_and_unwind_if_cycle_resulted(
225+
slot.database_key_index,
226+
INTERN_DURABILITY,
227+
changed_at,
228+
);
240229
<Q::Value>::from_intern_id(index)
241230
}
242231

@@ -313,9 +302,7 @@ where
313302
const CYCLE_STRATEGY: CycleRecoveryStrategy = CycleRecoveryStrategy::Panic;
314303

315304
fn new(_group_index: u16) -> Self {
316-
LookupInternedStorage {
317-
phantom: std::marker::PhantomData,
318-
}
305+
LookupInternedStorage { phantom: std::marker::PhantomData }
319306
}
320307

321308
fn fmt_index(
@@ -350,12 +337,11 @@ where
350337
let slot = interned_storage.lookup_value(index);
351338
let value = slot.value.clone();
352339
let interned_at = slot.interned_at;
353-
db.salsa_runtime()
354-
.report_query_read_and_unwind_if_cycle_resulted(
355-
slot.database_key_index,
356-
INTERN_DURABILITY,
357-
interned_at,
358-
);
340+
db.salsa_runtime().report_query_read_and_unwind_if_cycle_resulted(
341+
slot.database_key_index,
342+
INTERN_DURABILITY,
343+
interned_at,
344+
);
359345
value
360346
}
361347

0 commit comments

Comments
 (0)