From bd6b51360e71bef158a66abb1a480633e1feaaa1 Mon Sep 17 00:00:00 2001 From: Max Inden Date: Mon, 19 Oct 2020 11:48:17 +0200 Subject: [PATCH] static-metric/src/builder: Allow non-public label enums Imagine the following static metric generation: ```rust make_static_metric! { label_enum Methods { post, get, } struct MyStaticCounterVec: Counter { "method" => Methods, } } ``` This will roughly expand to: ```rust enum Methods { post, get, } use self::prometheus_static_scope_0::MyStaticCounterVec; mod prometheus_static_scope_0 { pub struct MyStaticCounterVec { pub post: MyStaticCounterVec2, pub get: MyStaticCounterVec2, } } ``` Rustc would complain that the `private type 'Methods' [is] in [the] public interface (error E0446)` `MyStaticCounterVec`. There is no reason for `MyStaticCounterVec` to be defined with visibility `pub`. This commit instead defines `MyStaticCounterVec` with `pub(super)` and thus `MyStaticCounterVec` does not expose the private type `Methods`. Signed-off-by: Max Inden --- static-metric/src/builder.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/static-metric/src/builder.rs b/static-metric/src/builder.rs index c717e776..5046a0d0 100644 --- a/static-metric/src/builder.rs +++ b/static-metric/src/builder.rs @@ -199,7 +199,7 @@ impl<'a> MetricBuilderContext<'a> { quote! { #[allow(missing_copy_implementations)] - pub struct #struct_name { + pub(super) struct #struct_name { #( pub #field_names: #member_types, )*