From 1a848a8b82248bff1d7c4aade27be9d8e2e74b06 Mon Sep 17 00:00:00 2001 From: Veetaha Date: Sun, 27 Oct 2024 00:12:14 +0000 Subject: [PATCH 1/2] Rename `__private` to `__` --- bon-macros/src/builder/builder_gen/builder_derives.rs | 8 ++++---- bon-macros/src/builder/builder_gen/mod.rs | 2 +- bon-macros/src/builder/builder_gen/state_mod.rs | 4 ++-- bon-macros/src/util/ide.rs | 2 +- bon/src/{__private => __}/cfg_eval.rs | 0 bon/src/{__private => __}/derives.rs | 0 bon/src/{__private => __}/ide.rs | 0 bon/src/{__private => __}/mod.rs | 2 +- bon/src/builder_state.rs | 4 ++-- bon/src/collections.rs | 6 +++--- bon/src/lib.rs | 4 ++-- 11 files changed, 16 insertions(+), 16 deletions(-) rename bon/src/{__private => __}/cfg_eval.rs (100%) rename bon/src/{__private => __}/derives.rs (100%) rename bon/src/{__private => __}/ide.rs (100%) rename bon/src/{__private => __}/mod.rs (96%) diff --git a/bon-macros/src/builder/builder_gen/builder_derives.rs b/bon-macros/src/builder/builder_gen/builder_derives.rs index faa3651a..6f2034d8 100644 --- a/bon-macros/src/builder/builder_gen/builder_derives.rs +++ b/bon-macros/src/builder/builder_gen/builder_derives.rs @@ -114,7 +114,7 @@ impl BuilderGenCtx { let ty = member.underlying_norm_ty(); quote! { - #bon::__private::derives::clone_member::<#ty>( + #bon::__::derives::clone_member::<#ty>( &self.#named_members_field.#member_index ) } @@ -170,7 +170,7 @@ impl BuilderGenCtx { if let Some(value) = &self.#named_members_field.#member_index { output.field( #member_ident_str, - #bon::__private::derives::as_dyn_debug::<#member_ty>(value) + #bon::__::derives::as_dyn_debug::<#member_ty>(value) ); } }) @@ -182,7 +182,7 @@ impl BuilderGenCtx { Some(quote! { output.field( #member_ident_str, - #bon::__private::derives::as_dyn_debug::<#member_ty>( + #bon::__::derives::as_dyn_debug::<#member_ty>( &self.#start_fn_args_field.#member_index ) ); @@ -201,7 +201,7 @@ impl BuilderGenCtx { quote! { output.field( "self", - #bon::__private::derives::as_dyn_debug::<#ty>( + #bon::__::derives::as_dyn_debug::<#ty>( &self.#receiver_field ) ); diff --git a/bon-macros/src/builder/builder_gen/mod.rs b/bon-macros/src/builder/builder_gen/mod.rs index 588fd41a..b2e7fdf1 100644 --- a/bon-macros/src/builder/builder_gen/mod.rs +++ b/bon-macros/src/builder/builder_gen/mod.rs @@ -46,7 +46,7 @@ impl BuilderGenCtx { let builder_derives = self.builder_derives(); let default_allows = syn::parse_quote!(#[allow( - // We have a `deprecated` lint on all `bon::__private` items which we + // We have a `deprecated` lint on all `bon::__` items which we // use in the generated code extensively deprecated )]); diff --git a/bon-macros/src/builder/builder_gen/state_mod.rs b/bon-macros/src/builder/builder_gen/state_mod.rs index 5208903e..170fbb35 100644 --- a/bon-macros/src/builder/builder_gen/state_mod.rs +++ b/bon-macros/src/builder/builder_gen/state_mod.rs @@ -69,8 +69,8 @@ impl<'a> StateModGenCtx<'a> { #( #state_mod_docs )* #vis mod #state_mod_ident { #[doc(inline)] - #vis_child use #bon::__private::{IsSet, IsUnset}; - use #bon::__private::{Set, Unset}; + #vis_child use #bon::__::{IsSet, IsUnset}; + use #bon::__::{Set, Unset}; mod sealed { #vis_child_child struct Sealed; diff --git a/bon-macros/src/util/ide.rs b/bon-macros/src/util/ide.rs index 3a2bcc38..f869c4ab 100644 --- a/bon-macros/src/util/ide.rs +++ b/bon-macros/src/util/ide.rs @@ -254,7 +254,7 @@ impl CompletionsSchema { // to avoid Rust Analyzer from providing completions for the // `self` keyword in the `use` statement. It works because // `use self::self` is not a valid syntax. - use #bon::__private::ide #(::#module_name)* ::*; + use #bon::__::ide #(::#module_name)* ::*; use self::{ #( #paths as _, )* }; } diff --git a/bon/src/__private/cfg_eval.rs b/bon/src/__/cfg_eval.rs similarity index 100% rename from bon/src/__private/cfg_eval.rs rename to bon/src/__/cfg_eval.rs diff --git a/bon/src/__private/derives.rs b/bon/src/__/derives.rs similarity index 100% rename from bon/src/__private/derives.rs rename to bon/src/__/derives.rs diff --git a/bon/src/__private/ide.rs b/bon/src/__/ide.rs similarity index 100% rename from bon/src/__private/ide.rs rename to bon/src/__/ide.rs diff --git a/bon/src/__private/mod.rs b/bon/src/__/mod.rs similarity index 96% rename from bon/src/__private/mod.rs rename to bon/src/__/mod.rs index 8da87ec7..061b11bc 100644 --- a/bon/src/__private/mod.rs +++ b/bon/src/__/mod.rs @@ -19,7 +19,7 @@ mod cfg_eval; // This reexport is a private implementation detail and should not be used // directly! This reexport may change or be removed at any time between // patch releases. Use the export from your generated builder's state module -// directly instead of using this reexport from `bon::__private`. +// directly instead of using this reexport from `bon::__`. pub use crate::builder_state::{IsSet, IsUnset}; pub use rustversion; diff --git a/bon/src/builder_state.rs b/bon/src/builder_state.rs index 14dfca27..5bae1873 100644 --- a/bon/src/builder_state.rs +++ b/bon/src/builder_state.rs @@ -1,5 +1,5 @@ //! The items here are intentionally defined in a private module not inside of the -//! [`crate::__private`] module. This is because that module is marked with `#[deprecated]` +//! [`crate::__`] module. This is because that module is marked with `#[deprecated]` //! which makes all items defined in that module also deprecated. //! //! This is not the desired behavior for the items defined here. They are not deprecated, @@ -7,7 +7,7 @@ //! them through the `bon` crate. Instead, they should use the re-exports from the state //! module generated for the builder. -use crate::__private::{Sealed, Set, Unset}; +use crate::__::{Sealed, Set, Unset}; /// Marker trait that indicates that the member is set, i.e. at least /// one of its setters was called. diff --git a/bon/src/collections.rs b/bon/src/collections.rs index 3cbc2d85..e68b43d8 100644 --- a/bon/src/collections.rs +++ b/bon/src/collections.rs @@ -29,8 +29,8 @@ #[cfg_attr(docsrs, doc(cfg(any(feature = "std", feature = "alloc"))))] #[allow(edition_2024_expr_fragment_specifier)] macro_rules! vec { - () => ($crate::__private::alloc::vec::Vec::new()); - ($($item:expr),+ $(,)?) => ($crate::__private::alloc::vec![$(::core::convert::Into::into($item)),+ ]); + () => ($crate::__::alloc::vec::Vec::new()); + ($($item:expr),+ $(,)?) => ($crate::__::alloc::vec![$(::core::convert::Into::into($item)),+ ]); } /// Creates a fixed-size array literal with each element converted with [`Into`]. @@ -74,7 +74,7 @@ macro_rules! arr { #[cfg(test)] mod tests { #[cfg(feature = "alloc")] - use crate::__private::alloc::{string::String, vec::Vec}; + use crate::__::alloc::{string::String, vec::Vec}; use core::num::NonZeroU8; #[cfg(feature = "alloc")] diff --git a/bon/src/lib.rs b/bon/src/lib.rs index 6718fdde..bfc2a9ed 100644 --- a/bon/src/lib.rs +++ b/bon/src/lib.rs @@ -18,11 +18,11 @@ pub use bon_macros::{bon, builder, map, set, Builder}; mod collections; #[doc(hidden)] -#[deprecated = "the items from the `bon::__private` module are an implementation detail; \ +#[deprecated = "the items from the `bon::__` module are an implementation detail; \ they should not be used directly; if you found a need for this, then you are probably \ doing something wrong; feel free to open an issue/discussion in our GitHub repository \ (https://github.com/elastio/bon) or ask for help in our Discord server \ (https://discord.gg/QcBYSamw4c)"] -pub mod __private; +pub mod __; mod builder_state; From 791ef53f19a28f381aac0c3812bdf65e5eae5867 Mon Sep 17 00:00:00 2001 From: Veetaha Date: Sun, 27 Oct 2024 00:17:49 +0000 Subject: [PATCH 2/2] Update snapshots --- .../ui/compile_fail/attr_derive.stderr | 44 +++++++++---------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/bon/tests/integration/ui/compile_fail/attr_derive.stderr b/bon/tests/integration/ui/compile_fail/attr_derive.stderr index 99d8dc89..5ed93ecf 100644 --- a/bon/tests/integration/ui/compile_fail/attr_derive.stderr +++ b/bon/tests/integration/ui/compile_fail/attr_derive.stderr @@ -35,7 +35,7 @@ error[E0277]: the trait bound `NoTraitImpls: Clone` is not satisfied | ^^^^^^^^^^^^ the trait `Clone` is not implemented for `NoTraitImpls` | note: required by a bound in `clone_member` - --> src/__private/derives.rs + --> src/__/derives.rs | | pub fn clone_member(member: &Option) -> Option { | ^^^^^ required by this bound in `clone_member` @@ -52,7 +52,7 @@ error[E0277]: the trait bound `NoTraitImpls: Clone` is not satisfied | ^^^^^^^^^^^^ the trait `Clone` is not implemented for `NoTraitImpls` | note: required by a bound in `clone_member` - --> src/__private/derives.rs + --> src/__/derives.rs | | pub fn clone_member(member: &Option) -> Option { | ^^^^^ required by this bound in `clone_member` @@ -69,7 +69,7 @@ error[E0277]: the trait bound `NoTraitImpls: Clone` is not satisfied | ^^^^^^^^^^^^ the trait `Clone` is not implemented for `NoTraitImpls` | note: required by a bound in `clone_member` - --> src/__private/derives.rs + --> src/__/derives.rs | | pub fn clone_member(member: &Option) -> Option { | ^^^^^ required by this bound in `clone_member` @@ -88,7 +88,7 @@ error[E0277]: `NoTraitImpls` doesn't implement `Debug` = help: the trait `Debug` is not implemented for `NoTraitImpls` = note: add `#[derive(Debug)]` to `NoTraitImpls` or manually `impl Debug for NoTraitImpls` note: required by a bound in `as_dyn_debug` - --> src/__private/derives.rs + --> src/__/derives.rs | | pub fn as_dyn_debug(member: &T) -> &dyn Debug { | ^^^^^ required by this bound in `as_dyn_debug` @@ -107,7 +107,7 @@ error[E0277]: `NoTraitImpls` doesn't implement `Debug` = help: the trait `Debug` is not implemented for `NoTraitImpls` = note: add `#[derive(Debug)]` to `NoTraitImpls` or manually `impl Debug for NoTraitImpls` note: required by a bound in `as_dyn_debug` - --> src/__private/derives.rs + --> src/__/derives.rs | | pub fn as_dyn_debug(member: &T) -> &dyn Debug { | ^^^^^ required by this bound in `as_dyn_debug` @@ -126,7 +126,7 @@ error[E0277]: `NoTraitImpls` doesn't implement `Debug` = help: the trait `Debug` is not implemented for `NoTraitImpls` = note: add `#[derive(Debug)]` to `NoTraitImpls` or manually `impl Debug for NoTraitImpls` note: required by a bound in `as_dyn_debug` - --> src/__private/derives.rs + --> src/__/derives.rs | | pub fn as_dyn_debug(member: &T) -> &dyn Debug { | ^^^^^ required by this bound in `as_dyn_debug` @@ -145,7 +145,7 @@ error[E0277]: `NoTraitImpls` doesn't implement `Debug` = help: the trait `Debug` is not implemented for `NoTraitImpls` = note: add `#[derive(Debug)]` to `NoTraitImpls` or manually `impl Debug for NoTraitImpls` note: required by a bound in `as_dyn_debug` - --> src/__private/derives.rs + --> src/__/derives.rs | | pub fn as_dyn_debug(member: &T) -> &dyn Debug { | ^^^^^ required by this bound in `as_dyn_debug` @@ -174,7 +174,7 @@ error[E0277]: the trait bound `NoTraitImpls: Clone` is not satisfied | ^^^^^^^^^^^^ the trait `Clone` is not implemented for `NoTraitImpls` | note: required by a bound in `clone_member` - --> src/__private/derives.rs + --> src/__/derives.rs | | pub fn clone_member(member: &Option) -> Option { | ^^^^^ required by this bound in `clone_member` @@ -191,7 +191,7 @@ error[E0277]: the trait bound `NoTraitImpls: Clone` is not satisfied | ^^^^^^^^^^^^ the trait `Clone` is not implemented for `NoTraitImpls` | note: required by a bound in `clone_member` - --> src/__private/derives.rs + --> src/__/derives.rs | | pub fn clone_member(member: &Option) -> Option { | ^^^^^ required by this bound in `clone_member` @@ -208,7 +208,7 @@ error[E0277]: the trait bound `NoTraitImpls: Clone` is not satisfied | ^^^^^^^^^^^^ the trait `Clone` is not implemented for `NoTraitImpls` | note: required by a bound in `clone_member` - --> src/__private/derives.rs + --> src/__/derives.rs | | pub fn clone_member(member: &Option) -> Option { | ^^^^^ required by this bound in `clone_member` @@ -227,7 +227,7 @@ error[E0277]: `NoTraitImpls` doesn't implement `Debug` = help: the trait `Debug` is not implemented for `NoTraitImpls` = note: add `#[derive(Debug)]` to `NoTraitImpls` or manually `impl Debug for NoTraitImpls` note: required by a bound in `as_dyn_debug` - --> src/__private/derives.rs + --> src/__/derives.rs | | pub fn as_dyn_debug(member: &T) -> &dyn Debug { | ^^^^^ required by this bound in `as_dyn_debug` @@ -246,7 +246,7 @@ error[E0277]: `NoTraitImpls` doesn't implement `Debug` = help: the trait `Debug` is not implemented for `NoTraitImpls` = note: add `#[derive(Debug)]` to `NoTraitImpls` or manually `impl Debug for NoTraitImpls` note: required by a bound in `as_dyn_debug` - --> src/__private/derives.rs + --> src/__/derives.rs | | pub fn as_dyn_debug(member: &T) -> &dyn Debug { | ^^^^^ required by this bound in `as_dyn_debug` @@ -265,7 +265,7 @@ error[E0277]: `NoTraitImpls` doesn't implement `Debug` = help: the trait `Debug` is not implemented for `NoTraitImpls` = note: add `#[derive(Debug)]` to `NoTraitImpls` or manually `impl Debug for NoTraitImpls` note: required by a bound in `as_dyn_debug` - --> src/__private/derives.rs + --> src/__/derives.rs | | pub fn as_dyn_debug(member: &T) -> &dyn Debug { | ^^^^^ required by this bound in `as_dyn_debug` @@ -284,7 +284,7 @@ error[E0277]: `NoTraitImpls` doesn't implement `Debug` = help: the trait `Debug` is not implemented for `NoTraitImpls` = note: add `#[derive(Debug)]` to `NoTraitImpls` or manually `impl Debug for NoTraitImpls` note: required by a bound in `as_dyn_debug` - --> src/__private/derives.rs + --> src/__/derives.rs | | pub fn as_dyn_debug(member: &T) -> &dyn Debug { | ^^^^^ required by this bound in `as_dyn_debug` @@ -319,7 +319,7 @@ error[E0277]: the trait bound `NoTraitImpls: Clone` is not satisfied | ^^^^^^^^^^^^ the trait `Clone` is not implemented for `NoTraitImpls` | note: required by a bound in `clone_member` - --> src/__private/derives.rs + --> src/__/derives.rs | | pub fn clone_member(member: &Option) -> Option { | ^^^^^ required by this bound in `clone_member` @@ -336,7 +336,7 @@ error[E0277]: the trait bound `NoTraitImpls: Clone` is not satisfied | ^^^^^^^^^^^^ the trait `Clone` is not implemented for `NoTraitImpls` | note: required by a bound in `clone_member` - --> src/__private/derives.rs + --> src/__/derives.rs | | pub fn clone_member(member: &Option) -> Option { | ^^^^^ required by this bound in `clone_member` @@ -353,7 +353,7 @@ error[E0277]: the trait bound `NoTraitImpls: Clone` is not satisfied | ^^^^^^^^^^^^ the trait `Clone` is not implemented for `NoTraitImpls` | note: required by a bound in `clone_member` - --> src/__private/derives.rs + --> src/__/derives.rs | | pub fn clone_member(member: &Option) -> Option { | ^^^^^ required by this bound in `clone_member` @@ -372,7 +372,7 @@ error[E0277]: `StructContainsNonTrait` doesn't implement `Debug` = help: the trait `Debug` is not implemented for `StructContainsNonTrait` = note: add `#[derive(Debug)]` to `StructContainsNonTrait` or manually `impl Debug for StructContainsNonTrait` note: required by a bound in `as_dyn_debug` - --> src/__private/derives.rs + --> src/__/derives.rs | | pub fn as_dyn_debug(member: &T) -> &dyn Debug { | ^^^^^ required by this bound in `as_dyn_debug` @@ -386,7 +386,7 @@ error[E0277]: `NoTraitImpls` doesn't implement `Debug` = help: the trait `Debug` is not implemented for `NoTraitImpls` = note: add `#[derive(Debug)]` to `NoTraitImpls` or manually `impl Debug for NoTraitImpls` note: required by a bound in `as_dyn_debug` - --> src/__private/derives.rs + --> src/__/derives.rs | | pub fn as_dyn_debug(member: &T) -> &dyn Debug { | ^^^^^ required by this bound in `as_dyn_debug` @@ -405,7 +405,7 @@ error[E0277]: `NoTraitImpls` doesn't implement `Debug` = help: the trait `Debug` is not implemented for `NoTraitImpls` = note: add `#[derive(Debug)]` to `NoTraitImpls` or manually `impl Debug for NoTraitImpls` note: required by a bound in `as_dyn_debug` - --> src/__private/derives.rs + --> src/__/derives.rs | | pub fn as_dyn_debug(member: &T) -> &dyn Debug { | ^^^^^ required by this bound in `as_dyn_debug` @@ -424,7 +424,7 @@ error[E0277]: `NoTraitImpls` doesn't implement `Debug` = help: the trait `Debug` is not implemented for `NoTraitImpls` = note: add `#[derive(Debug)]` to `NoTraitImpls` or manually `impl Debug for NoTraitImpls` note: required by a bound in `as_dyn_debug` - --> src/__private/derives.rs + --> src/__/derives.rs | | pub fn as_dyn_debug(member: &T) -> &dyn Debug { | ^^^^^ required by this bound in `as_dyn_debug` @@ -443,7 +443,7 @@ error[E0277]: `NoTraitImpls` doesn't implement `Debug` = help: the trait `Debug` is not implemented for `NoTraitImpls` = note: add `#[derive(Debug)]` to `NoTraitImpls` or manually `impl Debug for NoTraitImpls` note: required by a bound in `as_dyn_debug` - --> src/__private/derives.rs + --> src/__/derives.rs | | pub fn as_dyn_debug(member: &T) -> &dyn Debug { | ^^^^^ required by this bound in `as_dyn_debug`