diff --git a/rustler/src/resource/mod.rs b/rustler/src/resource/mod.rs index d8023603..c647b4ae 100644 --- a/rustler/src/resource/mod.rs +++ b/rustler/src/resource/mod.rs @@ -18,21 +18,3 @@ pub use monitor::Monitor; pub use registration::Registration; pub use traits::Resource; use traits::ResourceExt; - -/// Deprecated resource registration method -/// -/// This macro will create a local `impl Resource` for the passed type and is thus incompatible -/// with upcoming Rust language changes. Please implement the `Resource` trait directly and -/// register it either using the `resource_impl` attribute or using the `Env::register` method: -/// ```ignore -/// fn on_load(env: Env) -> bool { -/// env.register::().is_ok() -/// } -/// ``` -#[macro_export] -macro_rules! resource { - ($struct_name:ty, $env: ident) => {{ - impl $crate::Resource for $struct_name {} - $env.register::<$struct_name>().is_ok() - }}; -} diff --git a/rustler_codegen/src/init.rs b/rustler_codegen/src/init.rs index 61857e11..7505072a 100644 --- a/rustler_codegen/src/init.rs +++ b/rustler_codegen/src/init.rs @@ -1,50 +1,24 @@ use proc_macro2::{Span, TokenStream}; -use quote::{quote, quote_spanned}; +use quote::quote; use syn::parse::{Parse, ParseStream}; -use syn::spanned::Spanned; use syn::{Ident, Result, Token}; #[derive(Debug)] pub struct InitMacroInput { name: syn::Lit, load: TokenStream, - maybe_warning: TokenStream, } impl Parse for InitMacroInput { fn parse(input: ParseStream) -> Result { let name = syn::Lit::parse(input)?; - let maybe_warning = if input.peek(syn::token::Comma) && input.peek2(syn::token::Bracket) { - // peeked, must be there - let _ = syn::token::Comma::parse(input).unwrap(); - if let Ok(funcs) = syn::ExprArray::parse(input) { - quote_spanned!(funcs.span() => - #[allow(dead_code)] - fn rustler_init() { - #[deprecated( - since = "0.34.0", - note = "Passing NIF functions explicitly is deprecated and this argument is ignored, please remove it" - )] - #[allow(non_upper_case_globals)] - const explicit_nif_functions: () = (); - let _ = explicit_nif_functions; - } - ) - } else { - quote!() - } - } else { - quote!() - }; - let options = parse_expr_assigns(input); let load = extract_option(options, "load"); Ok(InitMacroInput { name, - load, - maybe_warning, + load }) } } @@ -81,7 +55,6 @@ impl From for proc_macro2::TokenStream { fn from(input: InitMacroInput) -> Self { let name = input.name; let load = input.load; - let maybe_warning = input.maybe_warning; let inner = quote! { static mut NIF_ENTRY: Option = None; diff --git a/rustler_tests/native/rustler_test/src/lib.rs b/rustler_tests/native/rustler_test/src/lib.rs index e37e35be..ec023412 100644 --- a/rustler_tests/native/rustler_test/src/lib.rs +++ b/rustler_tests/native/rustler_test/src/lib.rs @@ -19,8 +19,7 @@ mod test_term; mod test_thread; mod test_tuple; -// Intentional usage of the explicit form (in an "invalid" way, listing a wrong set of functions) to ensure that the warning stays alive -rustler::init!("Elixir.RustlerTest", [deprecated, usage], load = load); +rustler::init!("Elixir.RustlerTest", load = load); fn load(env: rustler::Env, _: rustler::Term) -> bool { test_resource::on_load(env) diff --git a/rustler_tests/native/rustler_test/src/test_resource.rs b/rustler_tests/native/rustler_test/src/test_resource.rs index 1dc13de9..fb424175 100644 --- a/rustler_tests/native/rustler_test/src/test_resource.rs +++ b/rustler_tests/native/rustler_test/src/test_resource.rs @@ -5,6 +5,9 @@ pub struct TestResource { test_field: RwLock, } +#[rustler::resource_impl] +impl Resource for TestResource {} + struct TestMonitorResourceInner { mon: Option, down_called: bool, @@ -42,9 +45,7 @@ pub struct WithBinaries { impl Resource for WithBinaries {} pub fn on_load(env: Env) -> bool { - rustler::resource!(TestResource, env) - && env.register::().is_ok() - && env.register::().is_ok() + env.register::().is_ok() && env.register::().is_ok() } #[rustler::nif]