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

Supporting reexporting enumflags2::bitflags macro #48

Open
PPakalns opened this issue Jul 29, 2023 · 2 comments
Open

Supporting reexporting enumflags2::bitflags macro #48

PPakalns opened this issue Jul 29, 2023 · 2 comments
Labels
help wanted Extra attention is needed

Comments

@PPakalns
Copy link

Macro can not find enumflags2 crate if enumflags2 is reexported (pub use).

A lot of projects use one main crate to organize all crates that all crates in workspace may use.

If enumflags2 is used with this approach following errors are raised:

error[E0432]: unresolved import `enumflags2`
   --> simulation/src/blocks.rs:584:1
    |
584 | #[enumflags2::bitflags]
    | ^^^^^^^^^^^^^^^^^^^^^^^ help: a similar path exists: `self::enumflags2`
    |
    = note: this error originates in the attribute macro `enumflags2::bitflags` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0433]: failed to resolve: could not find `enumflags2` in the list of imported crates
   --> simulation/src/blocks.rs:584:1
    |
584 | #[enumflags2::bitflags]
    | ^^^^^^^^^^^^^^^^^^^^^^^ could not find `enumflags2` in the list of imported crates
    |
    = note: this error originates in the attribute macro `enumflags2::bitflags` (in Nightly builds, run with -Z macro-backtrace for more info)

Other crates try to fix this by introducing additional macro attributes that defines how to access the crate in that context.

For example strum crate requires additional attribute:

#[strum(crate = "strum")]
@meithecatte
Copy link
Owner

A lot of projects use one main crate to organize all crates that all crates in workspace may use.

Wouldn't it be easier to use Cargo's support for workspace dependencies?

ozaner added a commit to ozaner/flagged that referenced this issue Mar 12, 2024
Requires enumflags2 as a dependency. Can't reexport it since the
bitflags macro is not hygienic (see meithecatte/enumflags2#48).
ozaner added a commit to ozaner/flagged that referenced this issue Mar 18, 2024
Requires enumflags2 as a dependency. Can't reexport it since the
bitflags macro is not hygienic (see meithecatte/enumflags2#48).
ozaner added a commit to ozaner/flagged that referenced this issue Mar 18, 2024
Requires enumflags2 as a dependency. Can't reexport it since the
bitflags macro is not hygienic (see meithecatte/enumflags2#48).
ozaner added a commit to ozaner/flagged that referenced this issue Mar 18, 2024
Requires enumflags2 as a dependency. Can't reexport it since the
bitflags macro is not hygienic (see meithecatte/enumflags2#48).
@meithecatte
Copy link
Owner

@ozaner Just noticed your commits referencing this issue. I find your crate to be a compelling usecase for fixing this, though I don't think the solution currently being proposed would be any more convenient than what your README currently proposes.

If you're aware of any way for a proc macro to hygienically refer to its "parent" crate, please let me know!

@meithecatte meithecatte added the help wanted Extra attention is needed label Jun 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants