diff --git a/macros/core/src/service.rs b/macros/core/src/service.rs index 2b77bd63..6a8df420 100644 --- a/macros/core/src/service.rs +++ b/macros/core/src/service.rs @@ -108,12 +108,16 @@ fn gen_gservice_impl(args: TokenStream, service_impl: ItemImpl) -> TokenStream { ) }; + let service_base_types = service_args.items.iter().flat_map(|item| match item { + ServiceArg::Extends(paths) => paths, + }); + let service_handlers = discover_service_handlers(&service_impl); - if service_handlers.is_empty() { + if service_handlers.is_empty() && !service_base_types.clone().any(|_| true) { abort!( service_impl, - "`gservice` attribute requires impl to define at least one public method" + "`gservice` attribute requires impl to define at least one public method or extend another service" ); } diff --git a/macros/tests/ui/gservice_fails_no_handlers_found.rs b/macros/tests/ui/gservice_fails_no_handlers_or_extends_found.rs similarity index 100% rename from macros/tests/ui/gservice_fails_no_handlers_found.rs rename to macros/tests/ui/gservice_fails_no_handlers_or_extends_found.rs diff --git a/macros/tests/ui/gservice_fails_no_handlers_found.stderr b/macros/tests/ui/gservice_fails_no_handlers_or_extends_found.stderr similarity index 80% rename from macros/tests/ui/gservice_fails_no_handlers_found.stderr rename to macros/tests/ui/gservice_fails_no_handlers_or_extends_found.stderr index 39751bc1..00623aa8 100644 --- a/macros/tests/ui/gservice_fails_no_handlers_found.stderr +++ b/macros/tests/ui/gservice_fails_no_handlers_or_extends_found.stderr @@ -1,4 +1,4 @@ -error: `gservice` attribute requires impl to define at least one public method +error: `gservice` attribute requires impl to define at least one public method or extend another service --> tests/ui/gservice_fails_no_handlers_found.rs:6:1 | 6 | impl MyService {}