From 522494aa5cdf06574bbb2bdc0b796585ed20bf9b Mon Sep 17 00:00:00 2001 From: Lukas Kalbertodt Date: Sat, 24 Jul 2021 17:00:54 +0200 Subject: [PATCH] Fix derive macro for `pub(crate)` visibility --- macro/src/gen.rs | 5 +++++ src/lib.rs | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/macro/src/gen.rs b/macro/src/gen.rs index 6d969d1..243331d 100644 --- a/macro/src/gen.rs +++ b/macro/src/gen.rs @@ -333,6 +333,11 @@ fn inner_visibility(outer: &syn::Visibility) -> TokenStream { // The inherited one is relative to the parent module. syn::Visibility::Inherited => quote! { pub(super) }, + // For `pub(crate)` + syn::Visibility::Restricted(r) if r.path.is_ident("crate") && r.in_token.is_none() => { + quote! { pub(crate) } + }, + // If the path in the `pub(in )` visibility is absolute, we can // use it like that as well. syn::Visibility::Restricted(r) if r.path.leading_colon.is_some() => quote! { outer }, diff --git a/src/lib.rs b/src/lib.rs index 9e0b902..6fe5a95 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -90,7 +90,7 @@ pub trait Partial: for<'de> Deserialize<'de> { fn with_fallback(self, fallback: Self) -> Self; } -/// A source of configuration values for the configuration object `T`, e.g. a +/// A source of configuration values for the configuration object `C`, e.g. a /// file or environment variables. pub trait Source { /// Attempts to load a potentially partially configuration object.