add some comments

This commit is contained in:
XFFXFF 2022-08-09 08:13:21 +08:00
parent 80bfff8d7a
commit 9fb5f7a366
3 changed files with 15 additions and 10 deletions

View file

@ -27,22 +27,25 @@ pub(crate) struct Options<A: AllowedOptions> {
/// The `jar = <type>` option is used to indicate the jar; it defaults to `crate::jar`.
///
/// If this is `Some`, the value is the `<path>`.
/// If this is `Some`, the value is the `<type>`.
pub jar_ty: Option<syn::Type>,
/// The `db = <type>` option is used to indicate the db.
/// The `db = <path>` option is used to indicate the db.
///
/// If this is `Some`, the value is the `<type>`.
/// If this is `Some`, the value is the `<path>`.
pub db_path: Option<syn::Path>,
/// The `recovery_fn = <path>` option is used to indicate the recovery function.
///
/// If this is `Some`, the value is the `<path>`.
pub recovery_fn: Option<syn::Path>,
/// The `data = <ident>` option is used to define the name of the data type for an interned
/// struct.
///
/// If this is `Some`, the value is the `<ident>`.
pub data: Option<syn::Ident>,
pub recovery_fn: Option<syn::Path>,
/// Remember the `A` parameter, which plays no role after parsing.
phantom: PhantomData<A>,
}

View file

@ -136,9 +136,10 @@ fn fn_configuration(args: &Args, item_fn: &syn::ItemFn) -> Configuration {
let fn_ty = item_fn.sig.ident.clone();
// FIXME: these are hardcoded for now
let indices = (0..item_fn.sig.inputs.len() - 1).map(|i| Literal::usize_unsuffixed(i));
let (cycle_strategy, recover_fn) = if let Some(recovery_fn) = &args.recovery_fn {
// Create the `recover_from_cycle` function, which (a) maps from the interned id to the actual
// keys and then (b) invokes the recover function itself.
let cycle_strategy = CycleRecoveryStrategy::Fallback;
let cycle_fullback = parse_quote! {
@ -152,13 +153,12 @@ fn fn_configuration(args: &Args, item_fn: &syn::ItemFn) -> Configuration {
};
(cycle_strategy, cycle_fullback)
} else {
// When the `recovery_fn` attribute is not set, set `cycle_strategy` to `Panic`
let cycle_strategy = CycleRecoveryStrategy::Panic;
let cycle_panic = configuration::panic_cycle_recovery_fn();
(cycle_strategy, cycle_panic)
};
// let cycle_strategy = CycleRecoveryStrategy::Panic;
// let recover_fn = configuration::panic_cycle_recovery_fn();
let backdate_fn = configuration::should_backdate_value_fn(args.should_backdate());
// The type of the configuration struct; this has the same name as the fn itself.

View file

@ -40,9 +40,11 @@ use salsa::storage::HasJarsDyn;
// | Intra | Fallback | Both | Tracked | direct | cycle_revalidate |
// | Intra | Fallback | New | Tracked | direct | cycle_appears |
// | Intra | Fallback | Old | Tracked | direct | cycle_disappears |
// | Intra | Fallback | Old | Tracked | direct | cycle_disappears_durability |
// | Intra | Mixed | N/A | Tracked | direct | cycle_mixed_1 |
// | Intra | Mixed | N/A | Tracked | direct | cycle_mixed_2 |
// TODO: The following tests are not yet ported.
// | Intra | Fallback | Old | Tracked | direct | cycle_disappears_durability |
// | Cross | Fallback | N/A | Tracked | both | parallel/cycles.rs: recover_parallel_cycle |
// | Cross | Panic | N/A | Tracked | both | parallel/cycles.rs: panic_parallel_cycle |
@ -257,7 +259,7 @@ fn cycle_recovery_unchanged_twice() {
let abc = ABC::new(&mut db, CycleQuery::B, CycleQuery::A, CycleQuery::None);
assert!(cycle_a(&db, abc).is_err());
abc.set_c(&mut db, CycleQuery::A); // same value as default
abc.set_c(&mut db, CycleQuery::A); // force new revision
assert!(cycle_a(&db, abc).is_err());
}