mirror of
https://github.com/uuid-rs/uuid.git
synced 2025-09-29 14:01:06 +00:00
Merge pull request #694 from teohhanhui/fix/macro-hygiene
Fix macro hygiene
This commit is contained in:
commit
bd7df72944
@ -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};
|
||||
|
@ -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)]
|
||||
|
7
tests/ui/compile_pass/hygiene.rs
Normal file
7
tests/ui/compile_pass/hygiene.rs
Normal file
@ -0,0 +1,7 @@
|
||||
use uuid::{uuid, Uuid};
|
||||
|
||||
fn Ok() {}
|
||||
|
||||
const _: Uuid = uuid!("00000000-0000-0000-0000-000000000000");
|
||||
|
||||
fn main() {}
|
Loading…
x
Reference in New Issue
Block a user