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: remove now-unnecessary proc-macro-hack crate usage #256

Merged
merged 2 commits into from Jul 15, 2022
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
10 changes: 3 additions & 7 deletions phf/Cargo.toml
Expand Up @@ -19,15 +19,11 @@ default = ["std"]
std = ["phf_shared/std"]
uncased = ["phf_shared/uncased"]
unicase = ["phf_macros?/unicase", "phf_shared/unicase"]
macros = [
"phf_macros",
"proc-macro-hack",
]
macros = ["phf_macros"]

[dependencies]
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 }
phf_macros = { version = "0.10.0", optional = true, path = "../phf_macros" }
phf_shared = { version = "0.10.0", default-features = false, path = "../phf_shared" }
serde = { version = "1.0", optional = true }

[package.metadata.docs.rs]
Expand Down
4 changes: 0 additions & 4 deletions phf/src/lib.rs
Expand Up @@ -102,14 +102,12 @@ 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")]
Expand All @@ -131,14 +129,12 @@ 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)]
Expand Down
1 change: 0 additions & 1 deletion phf_macros/Cargo.toml
Expand Up @@ -20,7 +20,6 @@ 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"
Expand Down
8 changes: 4 additions & 4 deletions phf_macros/src/lib.rs
Expand Up @@ -285,15 +285,15 @@ fn build_ordered_map(entries: &[Entry], state: HashState) -> proc_macro2::TokenS
}
}

#[proc_macro_hack::proc_macro_hack]
#[proc_macro]
pub fn phf_map(input: TokenStream) -> TokenStream {
let map = parse_macro_input!(input as Map);
let state = phf_generator::generate_hash(&map.0);

build_map(&map.0, state).into()
}

#[proc_macro_hack::proc_macro_hack]
#[proc_macro]
pub fn phf_set(input: TokenStream) -> TokenStream {
let set = parse_macro_input!(input as Set);
let state = phf_generator::generate_hash(&set.0);
Expand All @@ -302,15 +302,15 @@ pub fn phf_set(input: TokenStream) -> TokenStream {
quote!(phf::Set { map: #map }).into()
}

#[proc_macro_hack::proc_macro_hack]
#[proc_macro]
pub fn phf_ordered_map(input: TokenStream) -> TokenStream {
let map = parse_macro_input!(input as Map);
let state = phf_generator::generate_hash(&map.0);

build_ordered_map(&map.0, state).into()
}

#[proc_macro_hack::proc_macro_hack]
#[proc_macro]
pub fn phf_ordered_set(input: TokenStream) -> TokenStream {
let set = parse_macro_input!(input as Set);
let state = phf_generator::generate_hash(&set.0);
Expand Down
Expand Up @@ -3,5 +3,3 @@ 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)
2 changes: 0 additions & 2 deletions phf_macros_tests/tests/compile-fail/bad-syntax.stderr
Expand Up @@ -3,5 +3,3 @@ 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)