Skip to content

Conversation

@Elliot-Roberts
Copy link
Contributor

@Elliot-Roberts Elliot-Roberts commented Oct 13, 2025

Issue

The tests in crates/cfg/src/tests.rs depend on the tt feature of that crate, but are not feature-gated behind it.

When tests are run from the workspace root, there is no error because the workspace enables the tt feature:

cfg = { path = "./crates/cfg", version = "0.0.0", features = ["tt"] }

But there are compile errors when trying to run that specific crate's tests via cargo test --package cfg or cd crates/cfg && cargo test. This also affects running tests via the VSCode "Run Test" inlay buttons or Test Explorer panel.

Fix

In this PR, I just made tt a required dependency of cfg, removing the feature.

I looked at all the places where this cfg crate is used, and it seems everywhere inherits the dependency spec from the workspace, and so enables the tt feature.

If it turns out having tt as an optional dependency is important, I'm up for making all the tests conditionally compiled, or potentially applying a workaround to enable the tt feature when compiling tests.

Having tt as an optional dependency is important, so instead this PR will enable the tt feature when compiling tests. There is not direct support in Cargo for doing this, so this is done by depending on ourselves by path with the feature enabled in the dev-dependencies section.

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Oct 13, 2025
@ShoyuVanilla
Copy link
Member

As cfg is published in crates.io and some crates are depending on it other than rust-analyzer ones, I think dev-dependency thing would be better

@Elliot-Roberts
Copy link
Contributor Author

Ah, thanks, I see that now. I've switched it to the workaround instead.

@ChayimFriedman2
Copy link
Contributor

Thanks!

@ChayimFriedman2 ChayimFriedman2 added this pull request to the merge queue Oct 15, 2025
Merged via the queue into rust-lang:master with commit fcfff08 Oct 15, 2025
15 checks passed
@rustbot rustbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Oct 15, 2025
@lnicola lnicola changed the title Fix compile error in crates/cfg tests due to tt feature minor: Fix compile error in crates/cfg tests due to tt feature Oct 15, 2025
mendelsshop pushed a commit to mendelsshop/rust-analyzer that referenced this pull request Oct 27, 2025
Fix compile error in `crates/cfg` tests due to `tt` feature
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.

4 participants