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

unicase feature is not compilable without phf_macros dependency #250

Closed
gootorov opened this issue May 2, 2022 · 1 comment · Fixed by #251
Closed

unicase feature is not compilable without phf_macros dependency #250

gootorov opened this issue May 2, 2022 · 1 comment · Fixed by #251

Comments

@gootorov
Copy link

gootorov commented May 2, 2022

Hi, consider the following main.rs:

use phf::phf_map;
use unicase::UniCase;

static MAP: phf::Map<UniCase<&'static str>, isize> = phf_map!(
   UniCase::ascii("FOO") => 10,
   UniCase::unicode("Bar") => 11,
);

fn main() {}

With Cargo.toml:

[package]
name = "rust_phf_issue"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
phf = { version = "0.10", features = ["macros", "unicase"] }
unicase = "2.6"

Then the code won't compile with the following error:

error: unsupported key expression
 --> src/main.rs:5:4
  |
5 |    UniCase::ascii("FOO") => 10,
  |    ^^^^^^^^^^^^^^^^^^^^^
  |
  = note: this error originates in the macro `proc_macro_call` (in Nightly builds, run with -Z macro-backtrace for more info)

error: could not compile `rust_phf_issue` due to previous error

Workaround: change dependencies in Cargo.toml to the following:

[dependencies]
phf = { version = "0.10", features = ["macros"] }
phf_macros = { version = "0.10", features = ["unicase"] }
unicase = "2.6"

and then it compiles just fine.
I'm not sure if this is intended or not. Perhaps some sub-feature in macros does not get activated when the unicase feature in phf is enabled?

@JohnTitor
Copy link
Member

It was impossible to enable them without the phf_macros as we have to enable phf_macros/unicase feature if only we use unicase + macros features on phf. But 1.60 supports weak dependency and it's possible now. I've opened #251 to support that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants