fix: pass -Zjson-target-spec for .json target specs#22435
Closed
MavenRain wants to merge 1 commit into
Closed
Conversation
Since rust-lang/cargo#16557, cargo metadata and cargo check reject `--filter-platform path/to/foo.json` and `--target path/to/foo.json` unless `-Zjson-target-spec` is also passed (which itself requires `-Zunstable-options`). rust-analyzer hits this whenever a user configures a JSON target spec via `rust-analyzer.cargo.target` or via `.cargo/config.toml`'s `[build] target = "...json"`, surfacing as a metadata failure on workspace load. Detect when the configured target ends in `.json` and push the flag in both code paths (cargo_workspace.rs for cargo metadata, build_dependencies.rs for cargo check). The existing `-Z` detection in each function then handles `-Zunstable-options` and the `__CARGO_TEST_CHANNEL_OVERRIDE_DO_NOT_USE_THIS` env var. Matches the existing `target.ends_with(".json")` idiom already used in workspace.rs and toolchain_info/target_tuple.rs. Closes rust-lang#21821. Signed-off-by: Onyeka Obi <softwareengineerasaservant@isurvivable.cv>
Contributor
|
See #21846 for why this simple approach doesn't work. |
Contributor
Author
OK, I'm looking |
Contributor
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Since rust-lang/cargo#16557, cargo metadata and cargo check reject
--filter-platform path/to/foo.jsonand--target path/to/foo.jsonunless-Zjson-target-specis also passed (which itself requires-Zunstable-options). rust-analyzer hits this whenever a user configures a JSON target spec viarust-analyzer.cargo.targetor via.cargo/config.toml's[build] target = "...json", surfacing as a metadata failure on workspace load.Detect when the configured target ends in
.jsonand push the flag in both code paths (cargo_workspace.rs for cargo metadata, build_dependencies.rs for cargo check). The existing-Zdetection in each function then handles-Zunstable-optionsand the__CARGO_TEST_CHANNEL_OVERRIDE_DO_NOT_USE_THISenv var.Matches the existing
target.ends_with(".json")idiom already used in workspace.rs and toolchain_info/target_tuple.rs.Closes #21821.