From 3497a03af642eb3098cbe2b90ddd2180cb94009a Mon Sep 17 00:00:00 2001 From: Nugine Date: Tue, 16 Nov 2021 12:39:49 +0800 Subject: [PATCH] rename feature `macros` to `macro-diagnostics` --- Cargo.toml | 4 ++-- README.md | 8 +++++--- examples/uuid_macro.rs | 5 +++-- macros/src/lib.rs | 4 ++-- src/lib.rs | 4 ++-- src/macros.rs | 12 ++++++------ tests/macros.rs | 2 +- 7 files changed, 21 insertions(+), 18 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 709d803e..dffd9d97 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -52,9 +52,9 @@ status = "actively-developed" repository = "uuid-rs/uuid" [features] -default = ["std"] +default = ["std", "macro-diagnostics"] std = [] -macros = ["uuid_macro"] +macro-diagnostics = ["uuid_macro"] v1 = ["atomic"] v3 = ["md-5"] diff --git a/README.md b/README.md index 3d0f52a3..da00a164 100644 --- a/README.md +++ b/README.md @@ -51,8 +51,10 @@ let my_uuid = Uuid::parse_str("67e55044-10b1-426f-9247-bb680e5fe0c8")?; assert_eq!(Some(Version::Random), my_uuid.get_version()); ``` -If you add the `macros` feature then you can parse UUIDs at compile time -instead of at runtime: +You can parse UUIDs at compile time instead of at runtime. + +If you add the `macro-diagnostics` feature then you can see much better +error messages. ```rust #[macro_use] @@ -78,7 +80,7 @@ various pieces of functionality: generate a `Uuid`. * `v5` - adds the `Uuid::new_v5` function and the ability to create a V5 UUID based on the SHA1 hash of some data. -* `macros` - adds the `uuid!` macro that can parse UUIDs at compile time. +* `macro-diagnostics` - enhance the diagnostics of `uuid!` macro. * `serde` - adds the ability to serialize and deserialize a `Uuid` using the `serde` crate. * `arbitrary` - adds an `Arbitrary` trait implementation to `Uuid`. diff --git a/examples/uuid_macro.rs b/examples/uuid_macro.rs index 9336a09d..c4ff0484 100644 --- a/examples/uuid_macro.rs +++ b/examples/uuid_macro.rs @@ -1,12 +1,13 @@ //! Using the `uuid!` macro. //! -//! If you enable the `macros` feature you can use the `uuid!` macro. //! `uuid!` will parse encoded UUIDs at compile time instead of at runtime. //! If you've got a fixed UUID string handy then consider using `uuid!` instead //! of `Uuid::parse_str` or `str::parse`. +//! +//! If you enable the `macro-diagnostics` feature, you can see much better +//! error messages. #[test] -#[cfg(feature = "macros")] fn parse_uuid_at_compile_time() { use uuid::uuid; diff --git a/macros/src/lib.rs b/macros/src/lib.rs index 22c6cea9..13237cde 100644 --- a/macros/src/lib.rs +++ b/macros/src/lib.rs @@ -1,11 +1,11 @@ //! Implementation details for the `uuid!` macro. //! //! This crate is not meant to be used directly. Instead, -//! you can use the `macros` feature of `uuid`: +//! you can use the `macro-diagnostics` feature of `uuid`: //! //! ```toml //! [dependencies.uuid] -//! features = ["macros"] +//! features = ["macro-diagnostics"] //! ``` use proc_macro::TokenStream; diff --git a/src/lib.rs b/src/lib.rs index 141e2a7a..64dde7f9 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -40,7 +40,7 @@ //! generate a UUID. //! * `v5` - adds the [`Uuid::new_v5`] function and the ability to create a V5 //! UUID based on the SHA1 hash of some data. -//! * `macros` - adds the `uuid!` macro that can parse UUIDs at compile time. +//! * `macro-diagnostics` - enhance the diagnostics of `uuid!` macro. //! * `serde` - adds the ability to serialize and deserialize a UUID using the //! `serde` crate. //! * `arbitrary` - adds an `Arbitrary` trait implementation to `Uuid`. @@ -212,7 +212,7 @@ mod external; #[macro_use] mod macros; -#[cfg(feature = "macros")] +#[cfg(feature = "macro-diagnostics")] pub extern crate uuid_macro; use crate::std::convert; diff --git a/src/macros.rs b/src/macros.rs index 51b98ae8..8be62d8a 100644 --- a/src/macros.rs +++ b/src/macros.rs @@ -1,7 +1,7 @@ macro_rules! define_uuid_macro { {$(#[$doc:meta])*} => { $(#[$doc])* - #[cfg(feature = "macros")] + #[cfg(feature = "macro-diagnostics")] #[macro_export] macro_rules! uuid { ($uuid:literal) => {{ @@ -10,7 +10,7 @@ macro_rules! define_uuid_macro { } $(#[$doc])* - #[cfg(not(feature = "macros"))] + #[cfg(not(feature = "macro-diagnostics"))] #[macro_export] macro_rules! uuid { ($uuid:literal) => {{ @@ -20,7 +20,7 @@ macro_rules! define_uuid_macro { // here triggers const_err // const_panic requires 1.57 #[allow(unconditional_panic)] - let _ = ["invalid uuid representation"][1]; + let _ = ["invalid uuid representation"][1]; loop {} // -> never type } @@ -31,7 +31,7 @@ macro_rules! define_uuid_macro { } } -define_uuid_macro!{ +define_uuid_macro! { /// Parse [`Uuid`][uuid::Uuid]s from string literals at compile time. /// /// ## Usage @@ -67,8 +67,8 @@ define_uuid_macro!{ /// let uuid: Uuid = uuid!("F9168C5E-ZEB2-4FAA-B6BF-329BF39FA1E4"); /// ``` /// -/// Enable the feature `macros` to see the error messages below. -/// +/// Enable the feature `macro-diagnostics` to see the error messages below. +/// /// Provides the following compilation error: /// /// ```txt diff --git a/tests/macros.rs b/tests/macros.rs index cdb8ee57..8748d96b 100644 --- a/tests/macros.rs +++ b/tests/macros.rs @@ -1,4 +1,4 @@ -#[cfg(feature = "macros")] +#[cfg(feature = "macro-diagnostics")] #[test] fn ui() { let t = trybuild::TestCases::new();