Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion components/salsa-macros/src/fn_util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ pub fn input_ids(hygiene: &Hygiene, sig: &syn::Signature, skip: usize) -> Vec<sy
}
}

hygiene.ident(&format!("input{}", index))
hygiene.ident(&format!("input{index}"))
})
.collect()
}
Expand Down
2 changes: 1 addition & 1 deletion components/salsa-macros/src/hygiene.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ impl Hygiene {
pub(crate) fn ident(&self, text: &str) -> syn::Ident {
// Make the default be `foo_` rather than `foo` -- this helps detect
// cases where people wrote `foo` instead of `#foo` or `$foo` in the generated code.
let mut buffer = format!("{}_", text);
let mut buffer = format!("{text}_");

while self.user_tokens.contains(&buffer) {
buffer.push('_');
Expand Down
2 changes: 1 addition & 1 deletion components/salsa-macros/src/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ impl<A: AllowedOptions> syn::parse::Parse for Options<A> {
} else {
return Err(syn::Error::new(
ident.span(),
format!("unrecognized option `{}`", ident),
format!("unrecognized option `{ident}`"),
));
}

Expand Down
7 changes: 2 additions & 5 deletions components/salsa-macros/src/salsa_struct.rs
Original file line number Diff line number Diff line change
Expand Up @@ -358,15 +358,12 @@ impl<'s> SalsaField<'s> {
if BANNED_FIELD_NAMES.iter().any(|n| *n == field_name_str) {
return Err(syn::Error::new(
field_name.span(),
format!(
"the field name `{}` is disallowed in salsa structs",
field_name_str
),
format!("the field name `{field_name_str}` is disallowed in salsa structs",),
));
}

let get_name = Ident::new(&field_name_str, field_name.span());
let set_name = Ident::new(&format!("set_{}", field_name_str), field_name.span());
let set_name = Ident::new(&format!("set_{field_name_str}",), field_name.span());
let mut result = SalsaField {
field,
has_tracked_attr: false,
Expand Down
11 changes: 5 additions & 6 deletions examples/lazy-input/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,15 @@ fn main() -> Result<()> {
let sum = compile(&db, initial);
let diagnostics = compile::accumulated::<Diagnostic>(&db, initial);
if diagnostics.is_empty() {
println!("Sum is: {}", sum);
println!("Sum is: {sum}");
} else {
for diagnostic in diagnostics {
println!("{}", diagnostic.0);
}
}

for log in db.logs.lock().unwrap().drain(..) {
eprintln!("{}", log);
eprintln!("{log}");
}

// Wait for file change events, the output can't change unless the
Expand Down Expand Up @@ -104,7 +104,7 @@ impl salsa::Database for LazyInputDatabase {
// don't log boring events
let event = event();
if let salsa::EventKind::WillExecute { .. } = event.kind {
self.logs.lock().unwrap().push(format!("{:?}", event));
self.logs.lock().unwrap().push(format!("{event:?}"));
}
}
}
Expand Down Expand Up @@ -177,8 +177,7 @@ fn parse(db: &dyn Db, input: File) -> ParsedFile<'_> {
db,
input,
Report::new(e).wrap_err(format!(
"First line ({}) could not be parsed as an integer",
line
"First line ({line}) could not be parsed as an integer"
)),
);
0
Expand All @@ -196,7 +195,7 @@ fn parse(db: &dyn Db, input: File) -> ParsedFile<'_> {
Diagnostic::push_error(
db,
input,
Report::new(err).wrap_err(format!("Failed to parse path: {}", path)),
Report::new(err).wrap_err(format!("Failed to parse path: {path}")),
);
return None;
}
Expand Down
10 changes: 5 additions & 5 deletions src/event.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::thread::ThreadId;

use crate::key::DatabaseKeyIndex;
use crate::{Id, Revision};
use crate::Revision;

/// The `Event` struct identifies various notable things that can
/// occur during salsa execution. Instances of this struct are given
Expand Down Expand Up @@ -101,17 +101,17 @@ pub enum EventKind {

/// Indicates that a value was newly interned.
DidInternValue {
// The ID of the interned value.
id: Id,
// The key of the interned value.
key: DatabaseKeyIndex,

// The revision the value was interned in.
revision: Revision,
},

/// Indicates that a previously interned value was read in a new revision.
DidReinternValue {
// The ID of the interned value.
id: Id,
// The key of the interned value.
key: DatabaseKeyIndex,

// The revision the value was interned in.
revision: Revision,
Expand Down
3 changes: 1 addition & 2 deletions src/function/fetch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,7 @@ where
panic!(
"dependency graph cycle when querying {database_key_index:#?}, \
set cycle_fn/cycle_initial to fixpoint iterate.\n\
Query stack:\n{:#?}",
stack,
Query stack:\n{stack:#?}",
);
}),
CycleRecoveryStrategy::Fixpoint => {
Expand Down
3 changes: 1 addition & 2 deletions src/function/maybe_changed_after.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,7 @@ where
panic!(
"dependency graph cycle when validating {database_key_index:#?}, \
set cycle_fn/cycle_initial to fixpoint iterate.\n\
Query stack:\n{:#?}",
stack,
Query stack:\n{stack:#?}",
);
}),
CycleRecoveryStrategy::FallbackImmediate => {
Expand Down
15 changes: 9 additions & 6 deletions src/interned.rs
Original file line number Diff line number Diff line change
Expand Up @@ -226,12 +226,14 @@ where
.get()
.expect("found the interned, so `found_value` should be set");

let index = self.database_key_index(id);

// Sync the value's revision.
if value.last_interned_at.load() < current_revision {
value.last_interned_at.store(current_revision);
db.salsa_event(&|| {
Event::new(EventKind::DidReinternValue {
id,
key: index,
revision: current_revision,
})
});
Expand All @@ -249,7 +251,6 @@ where
};

// Record a dependency on this value.
let index = self.database_key_index(id);
zalsa_local.report_tracked_read_simple(index, durability, value.first_interned_at);

return id;
Expand All @@ -268,13 +269,14 @@ where
Ok(slot) => {
let id = unsafe { slot.as_ref().0 };
let value = zalsa.table().get::<Value<C>>(id);
let index = self.database_key_index(id);

// Sync the value's revision.
if value.last_interned_at.load() < current_revision {
value.last_interned_at.store(current_revision);
db.salsa_event(&|| {
Event::new(EventKind::DidReinternValue {
id,
key: index,
revision: current_revision,
})
});
Expand All @@ -292,7 +294,6 @@ where
};

// Record a dependency on this value.
let index = self.database_key_index(id);
zalsa_local.report_tracked_read_simple(index, durability, value.first_interned_at);

id
Expand Down Expand Up @@ -335,7 +336,7 @@ where

db.salsa_event(&|| {
Event::new(EventKind::DidInternValue {
id,
key: index,
revision: current_revision,
})
});
Expand Down Expand Up @@ -417,8 +418,10 @@ where
));

db.salsa_event(&|| {
let index = self.database_key_index(input);

Event::new(EventKind::DidReinternValue {
id: input,
key: index,
revision: current_revision,
})
});
Expand Down
2 changes: 1 addition & 1 deletion tests/accumulate-chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,6 @@ fn accumulate_chain() {
"log d",
),
]"#]]
.assert_eq(&format!("{:#?}", logs));
.assert_eq(&format!("{logs:#?}"));
})
}
6 changes: 3 additions & 3 deletions tests/accumulate-dag.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ fn push_logs(db: &dyn Database, input: MyInput) {
fn push_a_logs(db: &dyn Database, input: MyInput) {
let count = input.field_a(db);
for i in 0..count {
Log(format!("log_a({} of {})", i, count)).accumulate(db);
Log(format!("log_a({i} of {count})")).accumulate(db);
}
}

Expand All @@ -34,7 +34,7 @@ fn push_b_logs(db: &dyn Database, input: MyInput) {
push_a_logs(db, input);
let count = input.field_b(db);
for i in 0..count {
Log(format!("log_b({} of {})", i, count)).accumulate(db);
Log(format!("log_b({i} of {count})")).accumulate(db);
}
}

Expand Down Expand Up @@ -62,6 +62,6 @@ fn accumulate_a_called_twice() {
"log_b(2 of 3)",
),
]"#]]
.assert_eq(&format!("{:#?}", logs));
.assert_eq(&format!("{logs:#?}"));
})
}
2 changes: 1 addition & 1 deletion tests/accumulate-execution-order.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,6 @@ fn accumulate_execution_order() {
"log c",
),
]"#]]
.assert_eq(&format!("{:#?}", logs));
.assert_eq(&format!("{logs:#?}"));
})
}
4 changes: 2 additions & 2 deletions tests/accumulate-from-tracked-fn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@ fn compute(db: &dyn salsa::Database, input: List) {
);
let result = if let Some(next) = input.next(db) {
let next_integers = compute::accumulated::<Integers>(db, next);
eprintln!("{:?}", next_integers);
eprintln!("{next_integers:?}");
let v = input.value(db) + next_integers.iter().map(|a| a.0).sum::<u32>();
eprintln!("input={:?} v={:?}", input.value(db), v);
v
} else {
input.value(db)
};
Integers(result).accumulate(db);
eprintln!("pushed result {:?}", result);
eprintln!("pushed result {result:?}");
}

#[test]
Expand Down
2 changes: 1 addition & 1 deletion tests/accumulate-no-duplicates.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,6 @@ fn accumulate_no_duplicates() {
"log e",
),
]"#]]
.assert_eq(&format!("{:#?}", logs));
.assert_eq(&format!("{logs:#?}"));
})
}
4 changes: 2 additions & 2 deletions tests/accumulate-reuse-workaround.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ struct Integers(u32);

#[salsa::tracked]
fn compute(db: &dyn LogDatabase, input: List) -> u32 {
db.push_log(format!("compute({:?})", input,));
db.push_log(format!("compute({input:?})",));

// always pushes 0
Integers(0).accumulate(db);
Expand All @@ -39,7 +39,7 @@ fn compute(db: &dyn LogDatabase, input: List) -> u32 {

#[salsa::tracked(return_ref)]
fn accumulated(db: &dyn LogDatabase, input: List) -> Vec<u32> {
db.push_log(format!("accumulated({:?})", input));
db.push_log(format!("accumulated({input:?})"));
compute::accumulated::<Integers>(db, input)
.into_iter()
.map(|a| a.0)
Expand Down
2 changes: 1 addition & 1 deletion tests/accumulate-reuse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ struct Integers(u32);

#[salsa::tracked]
fn compute(db: &dyn LogDatabase, input: List) -> u32 {
db.push_log(format!("compute({:?})", input,));
db.push_log(format!("compute({input:?})",));

// always pushes 0
Integers(0).accumulate(db);
Expand Down
20 changes: 10 additions & 10 deletions tests/accumulate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,20 +36,20 @@ fn push_logs(db: &dyn LogDatabase, input: MyInput) {
#[salsa::tracked]
fn push_a_logs(db: &dyn LogDatabase, input: MyInput) {
let field_a = input.field_a(db);
db.push_log(format!("push_a_logs({})", field_a));
db.push_log(format!("push_a_logs({field_a})"));

for i in 0..field_a {
Log(format!("log_a({} of {})", i, field_a)).accumulate(db);
Log(format!("log_a({i} of {field_a})")).accumulate(db);
}
}

#[salsa::tracked]
fn push_b_logs(db: &dyn LogDatabase, input: MyInput) {
let field_a = input.field_b(db);
db.push_log(format!("push_b_logs({})", field_a));
db.push_log(format!("push_b_logs({field_a})"));

for i in 0..field_a {
Log(format!("log_b({} of {})", i, field_a)).accumulate(db);
Log(format!("log_b({i} of {field_a})")).accumulate(db);
}
}

Expand Down Expand Up @@ -86,7 +86,7 @@ fn accumulate_once() {
"log_b(2 of 3)",
),
]"#]]
.assert_eq(&format!("{:#?}", logs));
.assert_eq(&format!("{logs:#?}"));
}

#[test]
Expand Down Expand Up @@ -114,7 +114,7 @@ fn change_a_from_2_to_0() {
"log_b(2 of 3)",
),
]"#]]
.assert_eq(&format!("{:#?}", logs));
.assert_eq(&format!("{logs:#?}"));
db.assert_logs(expect![[r#"
[
"push_logs(a = 2, b = 3)",
Expand All @@ -137,7 +137,7 @@ fn change_a_from_2_to_0() {
"log_b(2 of 3)",
),
]"#]]
.assert_eq(&format!("{:#?}", logs));
.assert_eq(&format!("{logs:#?}"));
db.assert_logs(expect![[r#"
[
"push_logs(a = 0, b = 3)",
Expand Down Expand Up @@ -169,7 +169,7 @@ fn change_a_from_2_to_1() {
"log_b(2 of 3)",
),
]"#]]
.assert_eq(&format!("{:#?}", logs));
.assert_eq(&format!("{logs:#?}"));
db.assert_logs(expect![[r#"
[
"push_logs(a = 2, b = 3)",
Expand All @@ -195,7 +195,7 @@ fn change_a_from_2_to_1() {
"log_b(2 of 3)",
),
]"#]]
.assert_eq(&format!("{:#?}", logs));
.assert_eq(&format!("{logs:#?}"));
db.assert_logs(expect![[r#"
[
"push_logs(a = 1, b = 3)",
Expand All @@ -219,7 +219,7 @@ fn get_a_logs_after_changing_b() {
"log_a(1 of 2)",
),
]"#]]
.assert_eq(&format!("{:#?}", logs));
.assert_eq(&format!("{logs:#?}"));
db.assert_logs(expect![[r#"
[
"push_a_logs(2)",
Expand Down
Loading