@@ -33,11 +33,6 @@ pub(crate) struct Options<A: AllowedOptions> {
3333 /// If this is `Some`, the value is the `no_lifetime` identifier.
3434 pub no_lifetime : Option < syn:: Ident > ,
3535
36- /// Signal we should not generate a `Clone` impl.
37- ///
38- /// If this is `Some`, the value is the `no_clone` identifier.
39- pub no_clone : Option < syn:: Ident > ,
40-
4136 /// The `singleton` option is used on input with only one field
4237 /// It allows the creation of convenient methods
4338 pub singleton : Option < syn:: Ident > ,
@@ -48,6 +43,13 @@ pub(crate) struct Options<A: AllowedOptions> {
4843 /// If this is `Some`, the value is the `specify` identifier.
4944 pub specify : Option < syn:: Ident > ,
5045
46+ /// The `non_update_return_type` option is used to signal that a tracked function's
47+ /// return type does not require `Update` to be implemented. This is unsafe and
48+ /// generally discouraged as it allows for dangling references.
49+ ///
50+ /// If this is `Some`, the value is the `non_update_return_type` identifier.
51+ pub non_update_return_type : Option < syn:: Ident > ,
52+
5153 /// The `db = <path>` option is used to indicate the db.
5254 ///
5355 /// If this is `Some`, the value is the `<path>`.
@@ -100,10 +102,10 @@ impl<A: AllowedOptions> Default for Options<A> {
100102 Self {
101103 returns : Default :: default ( ) ,
102104 specify : Default :: default ( ) ,
105+ non_update_return_type : Default :: default ( ) ,
103106 no_eq : Default :: default ( ) ,
104107 debug : Default :: default ( ) ,
105108 no_lifetime : Default :: default ( ) ,
106- no_clone : Default :: default ( ) ,
107109 db_path : Default :: default ( ) ,
108110 cycle_fn : Default :: default ( ) ,
109111 cycle_initial : Default :: default ( ) ,
@@ -125,7 +127,7 @@ pub(crate) trait AllowedOptions {
125127 const NO_EQ : bool ;
126128 const DEBUG : bool ;
127129 const NO_LIFETIME : bool ;
128- const NO_CLONE : bool ;
130+ const NON_UPDATE_RETURN_TYPE : bool ;
129131 const SINGLETON : bool ;
130132 const DATA : bool ;
131133 const DB : bool ;
@@ -199,18 +201,28 @@ impl<A: AllowedOptions> syn::parse::Parse for Options<A> {
199201 "`no_lifetime` option not allowed here" ,
200202 ) ) ;
201203 }
202- } else if ident == "no_clone" {
203- if A :: NO_CLONE {
204- if let Some ( old) = options. no_clone . replace ( ident) {
204+ } else if ident == "unsafe" {
205+ if A :: NON_UPDATE_RETURN_TYPE {
206+ let content;
207+ parenthesized ! ( content in input) ;
208+ let ident = syn:: Ident :: parse_any ( & content) ?;
209+ if ident == "non_update_return_type" {
210+ if let Some ( old) = options. non_update_return_type . replace ( ident) {
211+ return Err ( syn:: Error :: new (
212+ old. span ( ) ,
213+ "option `non_update_return_type` provided twice" ,
214+ ) ) ;
215+ }
216+ } else {
205217 return Err ( syn:: Error :: new (
206- old . span ( ) ,
207- "option `no_clone` provided twice " ,
218+ ident . span ( ) ,
219+ "expected `non_update_return_type` " ,
208220 ) ) ;
209221 }
210222 } else {
211223 return Err ( syn:: Error :: new (
212224 ident. span ( ) ,
213- "`no_clone` option not allowed here" ,
225+ "`unsafe` options not allowed here" ,
214226 ) ) ;
215227 }
216228 } else if ident == "singleton" {
0 commit comments