Skip to content
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

Markers are unsupported #2

Open
adenine-dev opened this issue Jul 14, 2022 · 2 comments
Open

Markers are unsupported #2

adenine-dev opened this issue Jul 14, 2022 · 2 comments

Comments

@adenine-dev
Copy link

The following sample

use std::marker::PhantomData;

#[bitfield(u32)]
pub struct Foo<T> {
    _unused: u32,

    _marker: PhantomData<T>,
}

Fails to compile with the following error:

error: unsupported type
  --> main.rs:9:14
  |
9 |     _marker: PhantomData<T>,
  |              ^^^^^^^^^^^^^^

While some types should indeed be unsupported, markers probably should be supported, maybe even all zero size types? Not sure how one would go about fixing this other than potentially just extending type_bits to support marker types, but this disqualifies user defined markers, so doesn't seem like the best solution.

@wrenger
Copy link
Owner

wrenger commented Jul 20, 2022

Well yes, maybe the best idea would be to just support zero sized types for fields without accessors (prefixed with _).
However, it is somewhat difficult to find out the size of a type in a procedural macro, as it has no access to detailed type information (only basic Tokens). With generics this becomes even more difficult...

@wrenger
Copy link
Owner

wrenger commented Dec 22, 2022

Zero-sized members are now supported (prefixed by #[bits(0)]). They are ignored by the bitfield generation.
Generics, however, are still difficult. I might look into that in the future, but I can't promise.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants