Skip to content

Fix lalrpop-util missing the "lexer" feature under Cargo resolver v2 - #63

Open
KoenZandvlietAltius wants to merge 1 commit into
scallop-lang:masterfrom
KoenZandvlietAltius:fix/lalrpop-util-lexer-feature
Open

Fix lalrpop-util missing the "lexer" feature under Cargo resolver v2#63
KoenZandvlietAltius wants to merge 1 commit into
scallop-lang:masterfrom
KoenZandvlietAltius:fix/lalrpop-util-lexer-feature

Conversation

@KoenZandvlietAltius

Copy link
Copy Markdown

Problem

Consuming scallop-core as a plain Rust dependency from a project using Cargo's resolver v2 (the default for any crate on edition 2021+) fails to compile:

error[E0433]: cannot find `lexer` in `__lalrpop_util`

Cause

core/Cargo.toml requests lalrpop's "lexer" feature only under [build-dependencies] (used to generate the parser code from the grammar), but [dependencies]'s lalrpop-util (used by the generated code itself, at normal compile time) doesn't request that same feature:

[build-dependencies]
lalrpop = { version = "0.19.9", features = ["lexer"] }

[dependencies]
lalrpop-util = "0.19.9"  # missing features = ["lexer"]

Under Cargo's older resolver, build- and normal-dependency features were unified, so this went unnoticed. Resolver v2 correctly keeps them separate, so the generated grammar.rs can no longer find __lalrpop_util::lexer::MatcherBuilder. This doesn't surface when building scallop-core inside this repo's own workspace, only when it's pulled in as a dependency by a resolver-v2 consumer.

Fix

[dependencies]
lalrpop-util = { version = "0.19.9", features = ["lexer"] }

Verification

Found while embedding scallop-core as a Rust dependency in another project. Confirmed with cargo tree -i lalrpop-util, which shows the crate resolved twice — once with the feature (via the lalrpop build-dependency), once without (via scallop-core's own direct dependency). Verified both directions against that consuming project: reverting this change reproduces the exact 17 E0433/E0432 errors again, and applying it resolves them cleanly.

core/Cargo.toml requests lalrpop's "lexer" feature only under
[build-dependencies] (used to generate the parser from the grammar),
but [dependencies]'s lalrpop-util (used by the generated code itself)
doesn't request the same feature. Cargo's older resolver unified
build- and normal-dependency features, masking this; resolver v2
(the default for any consumer on edition 2021+) correctly keeps them
separate, so consumers depending on scallop-core directly fail with:

  error[E0433]: cannot find `lexer` in `__lalrpop_util`

This doesn't surface building scallop-core inside this repo's own
workspace, only when embedded as a dependency by a resolver-v2
consumer.

Verified: reproduced the failure by depending on scallop-core from a
resolver-v2 project, confirmed this one-line fix resolves it, and
confirmed reverting it reproduces the exact same 17 errors again.
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 this pull request may close these issues.

1 participant