File tree Expand file tree Collapse file tree 3 files changed +48
-2
lines changed Expand file tree Collapse file tree 3 files changed +48
-2
lines changed Original file line number Diff line number Diff line change @@ -110,7 +110,7 @@ macro_rules! setup_input_struct {
110
110
111
111
pub fn ingredient_mut( db: & mut dyn $zalsa:: Database ) -> ( & mut $zalsa_struct:: IngredientImpl <Self >, & mut $zalsa:: Runtime ) {
112
112
let zalsa_mut = db. zalsa_mut( ) ;
113
- let current_revision = zalsa_mut. new_revision( ) ;
113
+ zalsa_mut. new_revision( ) ;
114
114
let index = zalsa_mut. add_or_lookup_jar_by_type:: <$zalsa_struct:: JarImpl <$Configuration>>( ) ;
115
115
let ( ingredient, runtime) = zalsa_mut. lookup_ingredient_mut( index) ;
116
116
let ingredient = ingredient. assert_type_mut:: <$zalsa_struct:: IngredientImpl <Self >>( ) ;
Original file line number Diff line number Diff line change @@ -298,7 +298,22 @@ impl Macro {
298
298
) -> syn:: Result < ( ) > {
299
299
if let Some ( returns) = & args. returns {
300
300
if let syn:: ReturnType :: Type ( _, t) = & mut sig. output {
301
- * * t = parse_quote ! ( & #db_lt #t)
301
+ if returns == "copy" || returns == "clone" {
302
+ // leave as is
303
+ } else if returns == "ref" {
304
+ * * t = parse_quote ! ( & #db_lt #t)
305
+ } else if returns == "deref" {
306
+ * * t = parse_quote ! ( & #db_lt <#t as :: core:: ops:: Deref >:: Target )
307
+ } else if returns == "as_ref" {
308
+ * * t = parse_quote ! ( <#t as :: salsa:: SalsaAsRef >:: AsRef <#db_lt>)
309
+ } else if returns == "as_deref" {
310
+ * * t = parse_quote ! ( <#t as :: salsa:: SalsaAsDeref >:: AsDeref <#db_lt>)
311
+ } else {
312
+ return Err ( syn:: Error :: new_spanned (
313
+ returns,
314
+ format ! ( "Unknown returns mode `{returns}`" ) ,
315
+ ) ) ;
316
+ }
302
317
} else {
303
318
return Err ( syn:: Error :: new_spanned (
304
319
returns,
Original file line number Diff line number Diff line change
1
+ use salsa:: Database ;
2
+
3
+ #[ salsa:: input]
4
+ struct Input {
5
+ number : usize ,
6
+ }
7
+
8
+ #[ salsa:: tracked]
9
+ impl Input {
10
+ #[ salsa:: tracked( returns( deref) ) ]
11
+ fn test ( self , db : & dyn salsa:: Database ) -> Vec < String > {
12
+ ( 0 ..self . number ( db) ) . map ( |i| format ! ( "test {i}" ) ) . collect ( )
13
+ }
14
+ }
15
+
16
+ #[ test]
17
+ fn invoke ( ) {
18
+ salsa:: DatabaseImpl :: new ( ) . attach ( |db| {
19
+ let input = Input :: new ( db, 3 ) ;
20
+ let x: & [ String ] = input. test ( db) ;
21
+
22
+ assert_eq ! (
23
+ x,
24
+ & [
25
+ "test 0" . to_string( ) ,
26
+ "test 1" . to_string( ) ,
27
+ "test 2" . to_string( )
28
+ ]
29
+ ) ;
30
+ } )
31
+ }
You can’t perform that action at this time.
0 commit comments