Enforce absolute paths in all macro_rules and call_site sections of proc macros - #6
Open
anglesideangle wants to merge 1 commit into
Open
Enforce absolute paths in all macro_rules and call_site sections of proc macros#6anglesideangle wants to merge 1 commit into
anglesideangle wants to merge 1 commit into
Conversation
This replaces all call-site instances of e.g. `Result` with `::core::result::Result`, and re-exports whippyunits' dependency crates (`num_traits`, `whippyunits_core`, `whippyunits_proc_macros`) for use within whippyunits macros as e.g. `$crate::__private_num_traits`. It also adds `macro_hygiene_tests` for shadowing issues and a `transitive_dependency` test for ensuring a crate depending on whippyunits can successfully compile without itself depending on `num_traits` or `whippyunits_core`/`whippyunits_proc_macros`.
anglesideangle
force-pushed
the
hygenic-macros
branch
from
July 7, 2026 22:31
cba44db to
ef4808d
Compare
anglesideangle
marked this pull request as ready for review
July 7, 2026 22:32
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This replaces all call-site instances of e.g.
Resultwith::core::result::Result, and re-exports whippyunits' dependency crates (num_traits,whippyunits_core,whippyunits_proc_macros) for use within whippyunits macros as e.g.$crate::__private_num_traits. It also addsmacro_hygiene_testsfor shadowing issues and atransitive_dependencytest for ensuring a crate depending on whippyunits can successfully compile without itself depending onnum_traitsorwhippyunits_core/whippyunits_proc_macros.A few notes:
$crate::mechanism that is used for macro_rules, so they currently directly referencewhippyunits::paths. This would break if, e.g. they are in the same scope as astruct whippyunitsor a dependent crate imports whippyunits under a different name (wpiunits = { package = "whippyunits", version = "0.2" }). There seems to be proc-macro-crate to address this, but that's adding a dep so I didn't implement it here. What are your thoughts on this?DynDimensionExponentsandScaleExponentsbetweenwhippyunits_proc_macros::compute_unit_dimensionsand variousserializationmacros becausewhippyunits_proc_macrodoesn't re-exportwhippyunits_corefor something like the$crate::__private_whippyunits_corehackSome of the grunt work in this PR was done by an llm, but I've thoroughly reviewed and edited its output, and written more concise docs.
It also seems my editor's autoformatting caused a bit of churn. I can make a follow up PR enforcing formatting and strict clippy rules