Repository: rust-phf/rust-phf
Pull request #257 (2022-07-15 23:10:18)

Make crates edition 2021
Signed-off-by: Yuki Okushi <jtitor@2k36.org>


Patch:
diff --git a/phf/Cargo.toml b/phf/Cargo.toml
index 9f8f0d8..b7da89d 100644
--- a/phf/Cargo.toml
+++ b/phf/Cargo.toml
@@ -5,7 +5,7 @@ version = "0.10.1"
 license = "MIT"
 description = "Runtime support for perfect hash function data structures"
 repository = "https://github.com/sfackler/rust-phf"
-edition = "2018"
+edition = "2021"
 readme = "../README.md"
 rust-version = "1.60"
 
@@ -19,11 +19,15 @@ default = ["std"]
 std = ["phf_shared/std"]
 uncased = ["phf_shared/uncased"]
 unicase = ["phf_macros?/unicase", "phf_shared/unicase"]
-macros = ["phf_macros"]
+macros = [
+    "phf_macros",
+    "proc-macro-hack",
+]
 
 [dependencies]
-phf_macros = { version = "0.10.0", optional = true, path = "../phf_macros" }
-phf_shared = { version = "0.10.0", default-features = false, path = "../phf_shared" }
+proc-macro-hack = { version = "0.5.4", optional = true }
+phf_macros = { version = "0.10.0", optional = true }
+phf_shared = { version = "0.10.0", default-features = false }
 serde = { version = "1.0", optional = true }
 
 [package.metadata.docs.rs]
diff --git a/phf/src/lib.rs b/phf/src/lib.rs
index 916538b..252dc71 100644
--- a/phf/src/lib.rs
+++ b/phf/src/lib.rs
@@ -102,12 +102,14 @@ extern crate std as core;
 ///     assert_eq!(MY_MAP["hello"], 1);
 /// }
 /// ```
+#[proc_macro_hack::proc_macro_hack]
 pub use phf_macros::phf_map;
 
 #[cfg(feature = "macros")]
 /// Macro to create a `static` (compile-time) [`OrderedMap`].
 ///
 /// Requires the `macros` feature. Same usage as [`phf_map`].
+#[proc_macro_hack::proc_macro_hack]
 pub use phf_macros::phf_ordered_map;
 
 #[cfg(feature = "macros")]
@@ -129,12 +131,14 @@ pub use phf_macros::phf_ordered_map;
 ///     assert!(MY_SET.contains("hello world"));
 /// }
 /// ```
+#[proc_macro_hack::proc_macro_hack]
 pub use phf_macros::phf_set;
 
 #[cfg(feature = "macros")]
 /// Macro to create a `static` (compile-time) [`OrderedSet`].
 ///
 /// Requires the `macros` feature. Same usage as [`phf_set`].
+#[proc_macro_hack::proc_macro_hack]
 pub use phf_macros::phf_ordered_set;
 
 #[doc(inline)]
diff --git a/phf_codegen/Cargo.toml b/phf_codegen/Cargo.toml
index 7cbb079..6fa438b 100644
--- a/phf_codegen/Cargo.toml
+++ b/phf_codegen/Cargo.toml
@@ -5,7 +5,7 @@ version = "0.10.0"
 license = "MIT"
 description = "Codegen library for PHF types"
 repository = "https://github.com/sfackler/rust-phf"
-edition = "2018"
+edition = "2021"
 readme = "../README.md"
 rust-version = "1.60"
 
diff --git a/phf_generator/Cargo.toml b/phf_generator/Cargo.toml
index f44a233..dd0c4a4 100644
--- a/phf_generator/Cargo.toml
+++ b/phf_generator/Cargo.toml
@@ -5,7 +5,7 @@ version = "0.10.0"
 license = "MIT"
 description = "PHF generation logic"
 repository = "https://github.com/sfackler/rust-phf"
-edition = "2018"
+edition = "2021"
 rust-version = "1.60"
 
 [dependencies]
diff --git a/phf_macros/Cargo.toml b/phf_macros/Cargo.toml
index 6a55b90..3231b51 100644
--- a/phf_macros/Cargo.toml
+++ b/phf_macros/Cargo.toml
@@ -2,7 +2,7 @@
 name = "phf_macros"
 version = "0.10.0"
 authors = ["Steven Fackler <sfackler@gmail.com>"]
-edition = "2018"
+edition = "2021"
 license = "MIT"
 description = "Macros to generate types in the phf crate"
 repository = "https://github.com/sfackler/rust-phf"
@@ -20,6 +20,7 @@ unicase = ["unicase_", "phf_shared/unicase"]
 syn = { version = "1", features = ["full"] }
 quote = "1"
 proc-macro2 = "1"
+proc-macro-hack = "0.5.4"
 unicase_ = { package = "unicase", version = "2.4.0", optional = true }
 
 phf_generator = "0.10.0"
diff --git a/phf_macros/src/lib.rs b/phf_macros/src/lib.rs
index 22cad23..8161b05 100644
--- a/phf_macros/src/lib.rs
+++ b/phf_macros/src/lib.rs
@@ -285,7 +285,7 @@ fn build_ordered_map(entries: &[Entry], state: HashState) -> proc_macro2::TokenS
     }
 }
 
-#[proc_macro]
+#[proc_macro_hack::proc_macro_hack]
 pub fn phf_map(input: TokenStream) -> TokenStream {
     let map = parse_macro_input!(input as Map);
     let state = phf_generator::generate_hash(&map.0);
@@ -293,7 +293,7 @@ pub fn phf_map(input: TokenStream) -> TokenStream {
     build_map(&map.0, state).into()
 }
 
-#[proc_macro]
+#[proc_macro_hack::proc_macro_hack]
 pub fn phf_set(input: TokenStream) -> TokenStream {
     let set = parse_macro_input!(input as Set);
     let state = phf_generator::generate_hash(&set.0);
@@ -302,7 +302,7 @@ pub fn phf_set(input: TokenStream) -> TokenStream {
     quote!(phf::Set { map: #map }).into()
 }
 
-#[proc_macro]
+#[proc_macro_hack::proc_macro_hack]
 pub fn phf_ordered_map(input: TokenStream) -> TokenStream {
     let map = parse_macro_input!(input as Map);
     let state = phf_generator::generate_hash(&map.0);
@@ -310,7 +310,7 @@ pub fn phf_ordered_map(input: TokenStream) -> TokenStream {
     build_ordered_map(&map.0, state).into()
 }
 
-#[proc_macro]
+#[proc_macro_hack::proc_macro_hack]
 pub fn phf_ordered_set(input: TokenStream) -> TokenStream {
     let set = parse_macro_input!(input as Set);
     let state = phf_generator::generate_hash(&set.0);
diff --git a/phf_shared/Cargo.toml b/phf_shared/Cargo.toml
index 67f63e4..9faee48 100644
--- a/phf_shared/Cargo.toml
+++ b/phf_shared/Cargo.toml
@@ -5,7 +5,7 @@ version = "0.10.0"
 license = "MIT"
 description = "Support code shared by PHF libraries"
 repository = "https://github.com/sfackler/rust-phf"
-edition = "2018"
+edition = "2021"
 rust-version = "1.60"
 
 [lib]


Test patch:
diff --git a/phf_codegen/test/Cargo.toml b/phf_codegen/test/Cargo.toml
index 4a85065..456d5cb 100644
--- a/phf_codegen/test/Cargo.toml
+++ b/phf_codegen/test/Cargo.toml
@@ -3,7 +3,7 @@ name = "phf_codegen_test"
 authors = ["Steven Fackler <sfackler@gmail.com>"]
 version = "0.0.0"
 build = "build.rs"
-edition = "2018"
+edition = "2021"
 
 [dependencies]
 phf = { version = "0.10", features = ["uncased", "unicase"] }
diff --git a/phf_macros_tests/Cargo.toml b/phf_macros_tests/Cargo.toml
index b57147d..c91209c 100644
--- a/phf_macros_tests/Cargo.toml
+++ b/phf_macros_tests/Cargo.toml
@@ -2,7 +2,7 @@
 name = "phf_macros_tests"
 version = "0.1.0"
 authors = ["Yuki Okushi <jtitor@2k36.org>"]
-edition = "2018"
+edition = "2021"
 rust-version = "1.60"
 
 # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
diff --git a/phf_macros_tests/tests/compile-fail-unicase/equivalent-keys.stderr b/phf_macros_tests/tests/compile-fail-unicase/equivalent-keys.stderr
index 29ea8e0..5ea1dff 100644
--- a/phf_macros_tests/tests/compile-fail-unicase/equivalent-keys.stderr
+++ b/phf_macros_tests/tests/compile-fail-unicase/equivalent-keys.stderr
@@ -3,3 +3,5 @@ error: duplicate key
   |
 6 |     UniCase::ascii("foo") => 42, //~ ERROR duplicate key UniCase("FOO")
   |     ^^^^^^^^^^^^^^^^^^^^^
+  |
+  = note: this error originates in the macro `proc_macro_call` (in Nightly builds, run with -Z macro-backtrace for more info)
diff --git a/phf_macros_tests/tests/compile-fail/bad-syntax.stderr b/phf_macros_tests/tests/compile-fail/bad-syntax.stderr
index 6b1f56b..131dce3 100644
--- a/phf_macros_tests/tests/compile-fail/bad-syntax.stderr
+++ b/phf_macros_tests/tests/compile-fail/bad-syntax.stderr
@@ -3,3 +3,5 @@ error: expected identifier
   |
 5 |     => //~ ERROR expected identifier
   |     ^^
+  |
+  = note: this error originates in the macro `proc_macro_call` (in Nightly builds, run with -Z macro-backtrace for more info)