From 3701c0007dca2b47422806d011d37cb3933db04f Mon Sep 17 00:00:00 2001 From: Faysal Aberkane Date: Thu, 19 Nov 2026 08:24:23 +0000 Subject: [PATCH] fix: make features enable the token layer they need With `default-features = false`, the dependency `moxy = { features = ["ast", "quote"] }` failed to compile with "unresolved import `moxy_token`": `quote` and `proc-macro2` enabled `moxy-token` features only through a weak dependency (`moxy-token?/quote`), which does not enable the optional `moxy-token` dependency itself, while the root crate re-exports `moxy_token::quoted`. Likewise `template` compiled alone, but the code `template!` generates names `::moxy::token`, which then does not exist. `ast`, `template`, `proc-macro2`, and `quote` now enable `token`, and `fmt` enables `ast`, as the README's feature table already states. A CI job checks `cargo check -p moxy --no-default-features --features ` for each feature alone, since the test job builds with all features. --- .github/workflows/ci.yaml | 19 +++++++++++++++++++ Cargo.toml | 10 +++++----- 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index fc508414..7de52557 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -47,6 +47,25 @@ jobs: - name: Test run: cargo test --workspace --all-features --locked + features: + name: Features + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v5 + + - name: Install Rust + uses: dtolnay/rust-toolchain@stable + + - name: Cache Cargo + uses: Swatinem/rust-cache@v2 + + - name: Check each feature alone + run: | + for feature in token ast template fmt diagnostic build macros derives serde proc-macro2 visit quote; do + cargo check -p moxy --no-default-features --features "$feature" --locked + done + lint: name: Lint runs-on: ubuntu-latest diff --git a/Cargo.toml b/Cargo.toml index 7067fa1b..95291118 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -83,17 +83,17 @@ workspace = true default = ["ast", "token"] derives = ["moxy-ast?/derives", "moxy-template?/derives"] full = ["ast", "token", "build", "fmt", "template", "macros", "derives", "diagnostic", "serde", "proc-macro2", "visit"] -ast = ["dep:moxy-ast"] +ast = ["dep:moxy-ast", "token"] build = ["dep:moxy-build"] -fmt = ["dep:moxy-fmt"] +fmt = ["dep:moxy-fmt", "ast"] token = ["dep:moxy-token"] -template = ["dep:moxy-template"] +template = ["dep:moxy-template", "token"] macros = ["dep:moxy-macros"] diagnostic = ["dep:moxy-diagnostic"] serde = ["moxy-ast?/serde", "moxy-token?/serde", "moxy-fmt?/serde"] -proc-macro2 = ["moxy-token?/proc-macro2"] +proc-macro2 = ["token", "moxy-token/proc-macro2"] visit = ["moxy-ast?/visit"] -quote = ["moxy-token?/quote", "proc-macro2"] +quote = ["proc-macro2", "moxy-token/quote"] [dependencies] moxy-ast = { workspace = true, optional = true }