Skip to content

Commit

Permalink
Refactor visibility options with #[darling(flatten)]
Browse files Browse the repository at this point in the history
This reduces code duplication and makes it impossible for the options structs to see an invalid visibility state.
  • Loading branch information
TedDriggs committed Feb 23, 2024
1 parent 233c3d8 commit 06ba461
Show file tree
Hide file tree
Showing 3 changed files with 96 additions and 195 deletions.
20 changes: 4 additions & 16 deletions derive_builder/tests/compile-fail/vis_conflict.stderr
@@ -1,28 +1,16 @@
error: `public` and `private` cannot be used together
--> tests/compile-fail/vis_conflict.rs:7:15
|
7 | #[builder(public, private)]
| ^^^^^^

error: `vis="..."` cannot be used with `public` or `private`
error: `public` and `vis` cannot be used together
--> tests/compile-fail/vis_conflict.rs:5:25
|
5 | #[builder(public, vis = "pub(crate)")]
| ^^^^^^^^^^^^

error: `public` and `private` cannot be used together
--> tests/compile-fail/vis_conflict.rs:12:57
--> tests/compile-fail/vis_conflict.rs:12:48
|
12 | #[builder(public, vis = "pub(crate)", build_fn(private, public))]
| ^^^^^^

error: `vis="..."` cannot be used with `public` or `private`
--> tests/compile-fail/vis_conflict.rs:14:30
|
14 | #[builder(private, vis = "pub")]
| ^^^^^
| ^^^^^^^

error: `vis="..."` cannot be used with `public` or `private`
error: `public` and `vis` cannot be used together
--> tests/compile-fail/vis_conflict.rs:12:25
|
12 | #[builder(public, vis = "pub(crate)", build_fn(private, public))]
Expand Down
2 changes: 1 addition & 1 deletion derive_builder_core/Cargo.toml
Expand Up @@ -21,7 +21,7 @@ clippy = []
lib_has_std = []

[dependencies]
darling = "0.20.6"
darling = "0.20.7"
proc-macro2 = "1.0.37"
quote = "1.0.35"
syn = { version = "2.0.15", features = ["full", "extra-traits"] }
Expand Down

0 comments on commit 06ba461

Please sign in to comment.