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

Make "unicase + macros" features work #251

Merged
merged 2 commits into from May 3, 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
9 changes: 6 additions & 3 deletions .github/workflows/ci.yml
Expand Up @@ -13,7 +13,7 @@ jobs:
fail-fast: false
matrix:
# MSRV and nightly
version: [1.51.0, nightly]
version: [1.60.0, nightly]
steps:
- uses: actions/checkout@v2

Expand All @@ -23,7 +23,7 @@ jobs:
rustup override set ${{ matrix.version }}

- name: Rustfmt check
if: matrix.version == '1.51.0'
if: matrix.version == '1.60.0'
run: |
rustup component add rustfmt
cargo fmt --all -- --check
Expand All @@ -32,7 +32,7 @@ jobs:
run: cargo test --workspace --exclude=phf_codegen_test

- name: phf_macros UI test
if: matrix.version == '1.51.0'
if: matrix.version == '1.60.0'
working-directory: phf_macros_tests
run: cargo test -- --ignored --test-threads=1

Expand All @@ -42,3 +42,6 @@ jobs:
- name: no_std build check
working-directory: phf
run: cargo build --no-default-features

- name: unicase + macros features check
run: cargo check -p unicase-example
5 changes: 5 additions & 0 deletions CHANGELOG.md
@@ -1,5 +1,10 @@
# Changelog

## Unreleased

* Bump up MSRV to 1.60
* Now the `unicase` feature works fine with the `macros` feature, doesn't need to import `phf-macros` directly.

## 0.10.1

* Allow serializing `Map` ([#244])
Expand Down
1 change: 1 addition & 0 deletions Cargo.toml
@@ -1,6 +1,7 @@
[workspace]
members = [
"phf",
"phf/examples/unicase-example",
"phf_codegen",
"phf_codegen/test",
"phf_generator",
Expand Down
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -13,7 +13,7 @@ a 100,000 entry map in roughly .4 seconds. By default statistics are not
produced, but if you set the environment variable `PHF_STATS` it will issue
a compiler note about how long it took.

MSRV (minimum supported rust version) is Rust 1.46.
MSRV (minimum supported rust version) is Rust 1.60.

## Usage

Expand Down
3 changes: 2 additions & 1 deletion phf/Cargo.toml
Expand Up @@ -7,6 +7,7 @@ description = "Runtime support for perfect hash function data structures"
repository = "https://github.com/sfackler/rust-phf"
edition = "2018"
readme = "../README.md"
rust-version = "1.60"

[lib]
name = "phf"
Expand All @@ -17,7 +18,7 @@ test = false
default = ["std"]
std = ["phf_shared/std"]
uncased = ["phf_shared/uncased"]
unicase = ["phf_shared/unicase"]
unicase = ["phf_macros?/unicase", "phf_shared/unicase"]
macros = [
"phf_macros",
"proc-macro-hack",
Expand Down
11 changes: 11 additions & 0 deletions phf/examples/unicase-example/Cargo.toml
@@ -0,0 +1,11 @@
[package]
name = "unicase-example"
version = "0.1.0"
edition = "2021"
rust-version = "1.60"

# 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"
9 changes: 9 additions & 0 deletions phf/examples/unicase-example/src/main.rs
@@ -0,0 +1,9 @@
use phf::phf_map;
use unicase::UniCase;

pub static MAP: phf::Map<UniCase<&'static str>, isize> = phf_map!(
UniCase::ascii("Foo") => 0,
UniCase::unicode("Bar") => 1,
);

fn main() {}
2 changes: 1 addition & 1 deletion phf/src/lib.rs
Expand Up @@ -7,7 +7,7 @@
//! produced, but if you set the environment variable `PHF_STATS` it will issue
//! a compiler note about how long it took.
//!
//! MSRV (minimum supported rust version) is Rust 1.46.
//! MSRV (minimum supported rust version) is Rust 1.60.
//!
//! ## Usage
//!
Expand Down
1 change: 1 addition & 0 deletions phf_codegen/Cargo.toml
Expand Up @@ -7,6 +7,7 @@ description = "Codegen library for PHF types"
repository = "https://github.com/sfackler/rust-phf"
edition = "2018"
readme = "../README.md"
rust-version = "1.60"

[dependencies]
phf_generator = "0.10.0"
Expand Down
1 change: 1 addition & 0 deletions phf_generator/Cargo.toml
Expand Up @@ -6,6 +6,7 @@ license = "MIT"
description = "PHF generation logic"
repository = "https://github.com/sfackler/rust-phf"
edition = "2018"
rust-version = "1.60"

[dependencies]
rand = { version = "0.8", features = ["small_rng"] }
Expand Down
1 change: 1 addition & 0 deletions phf_macros/Cargo.toml
Expand Up @@ -8,6 +8,7 @@ description = "Macros to generate types in the phf crate"
repository = "https://github.com/sfackler/rust-phf"
readme = "../README.md"
include = ["src/lib.rs"]
rust-version = "1.60"

[lib]
proc-macro = true
Expand Down
1 change: 1 addition & 0 deletions phf_macros_tests/Cargo.toml
Expand Up @@ -3,6 +3,7 @@ name = "phf_macros_tests"
version = "0.1.0"
authors = ["Yuki Okushi <jtitor@2k36.org>"]
edition = "2018"
rust-version = "1.60"

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

Expand Down
@@ -1,7 +1,7 @@
error: duplicate key
--> $DIR/equivalent-keys.rs:6:5
--> tests/compile-fail-unicase/equivalent-keys.rs:6:5
|
6 | UniCase::ascii("foo") => 42, //~ ERROR duplicate key UniCase("FOO")
| ^^^^^^^^^^^^^^^^^^^^^
|
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
= note: this error originates in the macro `proc_macro_call` (in Nightly builds, run with -Z macro-backtrace for more info)
4 changes: 2 additions & 2 deletions phf_macros_tests/tests/compile-fail/bad-syntax.stderr
@@ -1,7 +1,7 @@
error: expected identifier
--> $DIR/bad-syntax.rs:5:5
--> tests/compile-fail/bad-syntax.rs:5:5
|
5 | => //~ ERROR expected identifier
| ^^
|
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
= note: this error originates in the macro `proc_macro_call` (in Nightly builds, run with -Z macro-backtrace for more info)
1 change: 1 addition & 0 deletions phf_shared/Cargo.toml
Expand Up @@ -6,6 +6,7 @@ license = "MIT"
description = "Support code shared by PHF libraries"
repository = "https://github.com/sfackler/rust-phf"
edition = "2018"
rust-version = "1.60"

[lib]
name = "phf_shared"
Expand Down