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 macro hygiene #694

Merged
merged 1 commit into from Jul 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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() {}