@@ -81,6 +81,24 @@ pub(crate) fn export_arg_v2_deprecation(export: &Option<bool>, ident: &syn::Iden
8181 }
8282}
8383
84+ /// Emit a deprecation warning when `lib` is set on a contract type or error.
85+ /// The argument is a vestige of an earlier design that was never used and will
86+ /// be removed in a future release.
87+ pub ( crate ) fn lib_arg_deprecation ( lib : & Option < String > , ident : & syn:: Ident ) -> TokenStream2 {
88+ if lib. is_some ( ) {
89+ let marker = format_ident ! ( "__SOROBAN_LIB_ARG_DEPRECATED_FOR_{}" , ident) ;
90+ quote ! {
91+ #[ doc( hidden) ]
92+ #[ allow( non_upper_case_globals) ]
93+ #[ deprecated = "`lib` is deprecated and will be removed in a future release" ]
94+ const #marker: ( ) = ( ) ;
95+ const _: ( ) = #marker;
96+ }
97+ } else {
98+ TokenStream2 :: new ( )
99+ }
100+ }
101+
84102#[ proc_macro]
85103pub fn internal_symbol_short ( input : TokenStream ) -> TokenStream {
86104 let input = parse_macro_input ! ( input as LitStr ) ;
@@ -456,6 +474,7 @@ pub fn contracttype(metadata: TokenStream, input: TokenStream) -> TokenStream {
456474 Err ( e) => return e. to_compile_error ( ) . into ( ) ,
457475 }
458476 let export_deprecation = export_arg_v2_deprecation ( & args. export , ident) ;
477+ let lib_deprecation = lib_arg_deprecation ( & args. lib , ident) ;
459478 // Under `experimental_spec_shaking_v2` the spec is always emitted and
460479 // reachability determines what is retained, so the `export` argument is
461480 // ignored (a deprecation warning is emitted above). Otherwise, honor an
@@ -512,6 +531,7 @@ pub fn contracttype(metadata: TokenStream, input: TokenStream) -> TokenStream {
512531 quote ! {
513532 #input
514533 #export_deprecation
534+ #lib_deprecation
515535 #derived
516536 }
517537 . into ( )
@@ -533,6 +553,7 @@ pub fn contracterror(metadata: TokenStream, input: TokenStream) -> TokenStream {
533553 let ident = & input. ident ;
534554 let attrs = & input. attrs ;
535555 let export_deprecation = export_arg_v2_deprecation ( & args. export , ident) ;
556+ let lib_deprecation = lib_arg_deprecation ( & args. lib , ident) ;
536557 // Under `experimental_spec_shaking_v2` the spec is always emitted and
537558 // reachability determines what is retained, so the `export` argument is
538559 // ignored (a deprecation warning is emitted above). Otherwise, honor an
@@ -567,6 +588,7 @@ pub fn contracterror(metadata: TokenStream, input: TokenStream) -> TokenStream {
567588 quote ! {
568589 #input
569590 #export_deprecation
591+ #lib_deprecation
570592 #derived
571593 }
572594 . into ( )
0 commit comments