Skip to content

fix(core): emit compile_error for --no-default-features (#659)#661

Open
gustav-fff wants to merge 1 commit into
mainfrom
triage-bot/issue-659
Open

fix(core): emit compile_error for --no-default-features (#659)#661
gustav-fff wants to merge 1 commit into
mainfrom
triage-bot/issue-659

Conversation

@gustav-fff

Copy link
Copy Markdown
Collaborator

Closes #659

Root cause

fff-search has two mutually exclusive backend features (ripgrep default, zlob), but internal cfg gates for ripgrep-only code used cfg(not(feature = "zlob")) instead of cfg(feature = "ripgrep") — see crates/fff-core/src/ignore.rs:42, crates/fff-core/src/walk/mod.rs:16, crates/fff-core/src/constraints.rs:172 / 443 / 556 / 580. With --no-default-features neither feature is set, so the ripgrep branches were compiled but the ignore / globset deps (gated on dep:ignore / dep:globset behind the ripgrep feature) were absent, yielding 15 cascading "unresolved module or unlinked crate" errors.

Fix

  • Tighten the affected gates to all(not(feature = "zlob"), feature = "ripgrep") so the ripgrep code is skipped when the ripgrep feature is off.
  • Add a top-level compile_error! in crates/fff-core/src/lib.rs when neither backend feature is enabled, so the failure is a single actionable message instead of a cascade.

Steps to reproduce

Setup:

git clone https://github.com/dmtrKovalenko/fff.git
cd fff

Trigger (on pre-fix main):

cargo check -p fff-search --no-default-features

Expected: build succeeds, or cargo emits a clear diagnostic identifying the required feature.

Actual (pre-fix): 15 errors, first ones:

error[E0433]: failed to resolve: use of unresolved module or unlinked crate `ignore`
  --> crates/fff-core/src/ignore.rs:44:9
error[E0432]: unresolved import `ignore`
 --> crates/fff-core/src/walk/ripgrep.rs:5:5
error[E0433]: failed to resolve: use of unresolved module or unlinked crate `globset`
   --> crates/fff-core/src/constraints.rs:558:5
...
error: could not compile `fff-search` (lib) due to 15 previous errors

How verified

cargo check -p fff-search --no-default-features                    # single compile_error diagnostic
cargo check -p fff-search --no-default-features --features ripgrep # ok
cargo check -p fff-search                                          # ok (default = ripgrep)
cargo check -p fff-search --no-default-features --features zlob    # ok
cargo test  -p fff-search --lib --no-default-features --features ripgrep # 98 passed; 0 failed

Top of --no-default-features output after the fix:

error: fff-search requires either the `ripgrep` (default) or `zlob` feature. Enable one, e.g. `--features ripgrep` or `--features zlob`.

Automated triage via Gustav. Honk-Honk 🪿

`fff-search` supports two mutually exclusive backend features (`ripgrep`
default, or `zlob`) but internal cfg gates keyed off
`cfg(not(feature = "zlob"))`, meaning the ripgrep code compiled even
when the `ripgrep` feature (and its `ignore`/`globset` deps) was off.
Building with `--no-default-features` produced a wall of
"unresolved crate" errors.

Tighten the gates to `all(not(feature = "zlob"), feature = "ripgrep")`
and add a top-level `compile_error!` when neither backend is enabled,
so the failure is a single actionable message instead of 15 cascading
errors.

Refs #659
@gustav-fff

Copy link
Copy Markdown
Collaborator Author

[triage-bot] CI note: Fuzz Tests (windows-latest) failed with ##[error]The operation was canceled. at 20m17s while cargo was still compiling — a job-time cancellation, not a test assertion failure (see https://github.com/dmtrKovalenko/fff/actions/runs/28899402130/job/85732131660). This job passed on the previous main run (https://github.com/dmtrKovalenko/fff/actions/runs/28888568812/job/85694982189) and the diff here (cfg gate tightening + compile_error!) does not touch the fuzz path. Rerunning the job should be sufficient.

Honk-Honk 🪿

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.

[Bug]: Build failing with --no-default-features

1 participant