Skip to content

Commit

Permalink
Merge pull request #694 from teohhanhui/fix/macro-hygiene
Browse files Browse the repository at this point in the history
Fix macro hygiene
  • Loading branch information
KodrAus committed Jul 15, 2023
2 parents 0fc3101 + 1d1ae31 commit bd7df72
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
5 changes: 5 additions & 0 deletions src/lib.rs
Expand Up @@ -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};
Expand Down
4 changes: 2 additions & 2 deletions src/macros.rs
Expand Up @@ -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)]
Expand Down
7 changes: 7 additions & 0 deletions tests/ui/compile_pass/hygiene.rs
@@ -0,0 +1,7 @@
use uuid::{uuid, Uuid};

fn Ok() {}

const _: Uuid = uuid!("00000000-0000-0000-0000-000000000000");

fn main() {}

0 comments on commit bd7df72

Please sign in to comment.