Merge pull request #694 from teohhanhui/fix/macro-hygiene

Fix macro hygiene
This commit is contained in:
Ashley Mannix 2023-07-15 10:43:47 +10:00 committed by GitHub
commit bd7df72944
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 2 deletions

View File

@ -273,6 +273,11 @@ mod macros;
#[cfg(feature = "macro-diagnostics")]
pub extern crate uuid_macro_internal;
#[doc(hidden)]
pub mod __macro_support {
pub use crate::std::result::Result::{Err, Ok};
}
use crate::std::convert;
pub use crate::{builder::Builder, error::Error};

View File

@ -15,8 +15,8 @@ macro_rules! define_uuid_macro {
macro_rules! uuid {
($uuid:literal) => {{
const OUTPUT: $crate::Uuid = match $crate::Uuid::try_parse($uuid) {
Ok(u) => u,
Err(_) => {
$crate::__macro_support::Ok(u) => u,
$crate::__macro_support::Err(_) => {
// here triggers const_err
// const_panic requires 1.57
#[allow(unconditional_panic)]

View File

@ -0,0 +1,7 @@
use uuid::{uuid, Uuid};
fn Ok() {}
const _: Uuid = uuid!("00000000-0000-0000-0000-000000000000");
fn main() {}