Skip to content

ReadOnly access attribute causes compile error #53

@SQDexe

Description

@SQDexe

While fiddling with the crate, a particular bug occurred. If you tried adding an access permission attribute of value ro to a field of the struct in the attached example code, it would cause a compile error as seen below.

error[E0599]: no method named `into_bits` found for type `{integer}` in the current scope
  --> src\main.rs:43:1
   |
43 | #[bitfield(u8)]
   | ^^^^^^^^^^^^^^^ method not found in `{integer}`
   |
   = note: this error originates in the attribute macro `bitfield` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0599]: no method named `into_bits` found for type `u8` in the current scope
  --> src\main.rs:43:1
   |
43 | #[bitfield(u8)]
   | ^^^^^^^^^^^^^^^
   |
   = note: this error originates in the attribute macro `bitfield` (in Nightly builds, run with -Z macro-backtrace for more info)

For more information about this error, try `rustc --explain E0599`.
error: could not compile `bitfields-test` (bin "bitfields-test") due to 10 previous errors

In the example, both usable fields have this access modifier, but the error persists for either configuration of this attribute (only first, only second, both fields), and only when it's in ro mode. The rest of modes work just fine. Interestingly, other field attributes went through without any issues.

I tried some other examples from the documentation, and they all worked out of the box. It really seems this one should work too.

PS
Sorry if I'm unprofessional, this is the first public issue I posted.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions