-
Notifications
You must be signed in to change notification settings - Fork 194
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
Use const identifier in uuid macro #764
Conversation
Thanks @Vrajs16! We should be able to support this in the procedural macro too by modifying this block here: https://github.com/uuid-rs/uuid/blob/main/macros/src/lib.rs#L70-L83. We'd change it to parse a Is this something you'd like to take a shot at implementing? If not, I'll be happy to merge this change once it passes CI and update the macros myself. |
Hi @KodrAus, not sure how I would generate the same the code in const OUTPUT: $crate::Uuid = match $crate::Uuid::try_parse($uuid) {
$crate::__macro_support::Ok(u) => u,
$crate::__macro_support::Err(_) => panic!("invalid UUID"),
};
OUTPUT |
Ah, sorry I'd forgotten we still wrap the procedural macro in a regular macro-rules one. Duplicating the match arm in the case where |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @Vrajs16! This looks good to me.
[![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Type | Update | Change | |---|---|---|---| | [uuid](https://togithub.com/uuid-rs/uuid) | workspace.dependencies | minor | `1.9.1` -> `1.10.0` | --- ### Release Notes <details> <summary>uuid-rs/uuid (uuid)</summary> ### [`v1.10.0`](https://togithub.com/uuid-rs/uuid/releases/tag/1.10.0) [Compare Source](https://togithub.com/uuid-rs/uuid/compare/1.9.1...1.10.0) #### Deprecations This release deprecates and renames the following functions: - `Builder::from_rfc4122_timestamp` -> `Builder::from_gregorian_timestamp` - `Builder::from_sorted_rfc4122_timestamp` -> `Builder::from_sorted_gregorian_timestamp` - `Timestamp::from_rfc4122` -> `Timestamp::from_gregorian` - `Timestamp::to_rfc4122` -> `Timestamp::to_gregorian` #### What's Changed - Use const identifier in uuid macro by [@​Vrajs16](https://togithub.com/Vrajs16) in [uuid-rs/uuid#764 - Rename most methods referring to RFC4122 by [@​Mikopet](https://togithub.com/Mikopet) / [@​KodrAus](https://togithub.com/KodrAus) in [uuid-rs/uuid#765 - prepare for 1.10.0 release by [@​KodrAus](https://togithub.com/KodrAus) in [uuid-rs/uuid#766 #### New Contributors - [@​Vrajs16](https://togithub.com/Vrajs16) made their first contribution in [uuid-rs/uuid#764 **Full Changelog**: uuid-rs/uuid@1.9.1...1.10.0 </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://developer.mend.io/github/andrzejressel/pulumi-wasm).
[![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Type | Update | Change | |---|---|---|---| | [uuid](https://togithub.com/uuid-rs/uuid) | workspace.dependencies | minor | `1.9.1` -> `1.10.0` | --- ### Release Notes <details> <summary>uuid-rs/uuid (uuid)</summary> ### [`v1.10.0`](https://togithub.com/uuid-rs/uuid/releases/tag/1.10.0) [Compare Source](https://togithub.com/uuid-rs/uuid/compare/1.9.1...1.10.0) #### Deprecations This release deprecates and renames the following functions: - `Builder::from_rfc4122_timestamp` -> `Builder::from_gregorian_timestamp` - `Builder::from_sorted_rfc4122_timestamp` -> `Builder::from_sorted_gregorian_timestamp` - `Timestamp::from_rfc4122` -> `Timestamp::from_gregorian` - `Timestamp::to_rfc4122` -> `Timestamp::to_gregorian` #### What's Changed - Use const identifier in uuid macro by [@​Vrajs16](https://togithub.com/Vrajs16) in [uuid-rs/uuid#764 - Rename most methods referring to RFC4122 by [@​Mikopet](https://togithub.com/Mikopet) / [@​KodrAus](https://togithub.com/KodrAus) in [uuid-rs/uuid#765 - prepare for 1.10.0 release by [@​KodrAus](https://togithub.com/KodrAus) in [uuid-rs/uuid#766 #### New Contributors - [@​Vrajs16](https://togithub.com/Vrajs16) made their first contribution in [uuid-rs/uuid#764 **Full Changelog**: uuid-rs/uuid@1.9.1...1.10.0 </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Enabled. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://developer.mend.io/github/spiraldb/vortex). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy40MjUuMSIsInVwZGF0ZWRJblZlciI6IjM3LjQyNS4xIiwidGFyZ2V0QnJhbmNoIjoiZGV2ZWxvcCIsImxhYmVscyI6W119--> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Bumps uuid from 1.9.1 to 1.10.0. Release notes Sourced from uuid's releases. 1.10.0 Deprecations This release deprecates and renames the following functions: Builder::from_rfc4122_timestamp -> Builder::from_gregorian_timestamp Builder::from_sorted_rfc4122_timestamp -> Builder::from_sorted_gregorian_timestamp Timestamp::from_rfc4122 -> Timestamp::from_gregorian Timestamp::to_rfc4122 -> Timestamp::to_gregorian What's Changed Use const identifier in uuid macro by @Vrajs16 in uuid-rs/uuid#764 Rename most methods referring to RFC4122 by @Mikopet / @KodrAus in uuid-rs/uuid#765 prepare for 1.10.0 release by @KodrAus in uuid-rs/uuid#766 New Contributors @Vrajs16 made their first contribution in uuid-rs/uuid#764 Full Changelog: uuid-rs/uuid@1.9.1...1.10.0 Commits 4b4c590 Merge pull request #766 from uuid-rs/cargo/1.10.0 68eff32 Merge pull request #765 from uuid-rs/chore/time-fn-deprecations 3d5384d update docs and deprecation messages for timestamp fns de50f20 renaming rfc4122 functions 4a88417 prepare for 1.10.0 release 66b4fce Merge pull request #764 from Vrajs16/main 8896e26 Use expr instead of ident 09973d6 Added changes 6edf3e8 Use const identifer in uuid macro See full diff in compare view Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase. Dependabot commands and options You can trigger Dependabot actions by commenting on this PR: @dependabot rebase will rebase this PR @dependabot recreate will recreate this PR, overwriting any edits that have been made to it @dependabot merge will merge this PR after your CI passes on it @dependabot squash and merge will squash and merge this PR after your CI passes on it @dependabot cancel merge will cancel a previously requested merge and block automerging @dependabot reopen will reopen this PR if it is closed @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually @dependabot show <dependency name> ignore conditions will show all of the ignore conditions of the specified dependency @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
The code below works when the user doesn't enable
macro-diagnostics
feature.It's not possible to convert the value of identifier into a string literal at compile time, but is there another way we can go about this so we can give more details when this feature is enabled.
If not, we can just paste the same code inside the macro where macro-diagnostics is enabled so that at least there wouldn't be a compile time error.
Closes #756