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

Fix issue where #[cfg(...)] are not propogated to emitted debug implementation. #20

Merged
merged 3 commits into from
Jun 17, 2024

Conversation

chris-oo
Copy link
Contributor

@chris-oo chris-oo commented Jun 5, 2024

When using feature gates with debug derives, the generated debug implementation does not correctly cfg gate enums that should be cfg gated, resulting in code that does not compile with the given feature.

Fix this by making sure we emit [#cfg(...)] to the generated debug variants so that the code is correctly feature gated.

Fixes #19

@chris-oo
Copy link
Contributor Author

chris-oo commented Jun 5, 2024

I'm not an expert on proc macros, so if you have anything you'd like to see different, much appreciated!

@chris-oo
Copy link
Contributor Author

chris-oo commented Jun 7, 2024

Bump? @kupiakos I was hoping to get this soon, as there's some other changes that I'd like to merge in the igvm crate that needs this.

Red = 1,
Blue = 2,
/// Test doc
#[cfg(feature = "orange")]
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

D'you have any ideas for testing that this works correctly with the cfg enabled?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm... we could maybe have a test enabled feature and have an enumeration with cfg enabled on it? Perhaps I should have done that in the PR.

FWIW in the igvm repo we're testing both, but I can see about submitting a follow up PR to do the same here.

@kupiakos
Copy link
Owner

kupiakos commented Jun 17, 2024

Sorry for the delay! Published in v0.5.2.

@kupiakos kupiakos merged commit 16d6406 into kupiakos:main Jun 17, 2024
2 checks passed
@chris-oo
Copy link
Contributor Author

Thanks, no problem appreciate it!

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

Successfully merging this pull request may close these issues.

Debug macro generation does not observe #cfg(feature) gates correctly
2 participants