-
Notifications
You must be signed in to change notification settings - Fork 90
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Produce error for
default
with field.type
If `field.type` is used without `field.build`, a Move conversion is used instead of the OptionOrDefault conversion. This means that the presence of `field.type` prevents a field-level `default` from doing anything. Standard practice in derive_builder is to produce an error when parameters are not going to be used. Fixes #269
- Loading branch information
Showing
4 changed files
with
64 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 21 additions & 3 deletions
24
derive_builder/tests/compile-fail/builder_field_custom.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,23 @@ | ||
error: #[builder(default)] and #[builder(field(build="..."))] cannot be used together | ||
--> tests/compile-fail/builder_field_custom.rs:6:25 | ||
--> tests/compile-fail/builder_field_custom.rs:8:19 | ||
| | ||
6 | #[builder(default = "88", field(type = "usize", build = "self.ipsum + 42"))] | ||
| ^^^^ | ||
8 | default = "1", | ||
| ^^^ | ||
|
||
error: #[builder(default)] and #[builder(field(type="..."))] cannot be used together | ||
--> tests/compile-fail/builder_field_custom.rs:14:25 | ||
| | ||
14 | #[builder(default = "2", field(type = "usize"))] | ||
| ^^^ | ||
|
||
error: #[builder(default)] and #[builder(field(build="..."))] cannot be used together | ||
--> tests/compile-fail/builder_field_custom.rs:18:25 | ||
| | ||
18 | #[builder(default = "3", field(type = "usize", build = "self.ipsum + 42"))] | ||
| ^^^ | ||
|
||
error: #[builder(default)] and #[builder(field(type="..."))] cannot be used together | ||
--> tests/compile-fail/builder_field_custom.rs:18:25 | ||
| | ||
18 | #[builder(default = "3", field(type = "usize", build = "self.ipsum + 42"))] | ||
| ^^^ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters