-
Notifications
You must be signed in to change notification settings - Fork 16
allow value field names #127
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| // No issues with the private internal field value when a field is named value. | ||
| #[bitbybit::bitfield(u32, default = 0x0, debug)] | ||
| pub struct Data { | ||
| #[bit(15, rw)] | ||
| dparity: bool, | ||
| #[bits(0..=7, rw)] | ||
| value: u8, | ||
| } | ||
|
|
||
| pub fn main() {} |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -34,7 +34,7 @@ error[E0599]: no method named `with_a` found for struct `PartialTestAllowed<true | |
| | ^^^^^^ method not found in `PartialTestAllowed<true, true, false, false, false>` | ||
| | | ||
| = note: the method was found for | ||
| - `PartialTestAllowed<upper, false, c, b, false>` | ||
| - `PartialTestAllowed<__UPPER, false, __C, __B, false>` | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The original approach was explicitly to try and keep the output in the diagnostics as close to the user's code as possible, so changing their casing is unfortunate. We must address the issue with clashing with field names, of course, but we could handle that by exclusively changing
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. that would be a solution, but I think the diagnostics are still sufficient to know what the issue is. I can still do the special case solution. alternatively: what do you think about renaming the value field itself to
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| help: one of the expressions' fields has a method of the same name | ||
| | | ||
| 48 | TestAllowed::builder().with_upper(u4::new(0)).with_lower(u12::new(0)).value.with_a(u2::new(0)).build(); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this duplicated logic be moved to a separate function and called here and in 556?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
probably, yes..