Add --print target-spec-json-schema by Noratrieb · Pull Request #144498 · rust-lang/rust

@rustbot added S-waiting-on-author

Status: This is awaiting some action (such as code changes or more information) from the author.

T-compiler

Relevant to the compiler team, which will review and decide on the PR/issue.

labels

Jul 26, 2025

Noratrieb

@rustbot rustbot added A-tidy

Area: The tidy tool

T-bootstrap

Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)

labels

Jul 26, 2025

@Noratrieb Noratrieb marked this pull request as ready for review

July 27, 2025 17:52

@rustbot rustbot added S-waiting-on-review

Status: Awaiting review from the assignee but also interested parties.

and removed S-waiting-on-author

Status: This is awaiting some action (such as code changes or more information) from the author.

labels

Jul 27, 2025

jieyouxu

@jieyouxu jieyouxu added S-waiting-on-MCP

Status: PR has a compiler MCP and is waiting for the compiler MCP to complete.

and removed S-waiting-on-review

Status: Awaiting review from the assignee but also interested parties.

labels

Jul 29, 2025
With this macro we only need to enumerate every variant once. This saves
a lot of duplication already between the definition, the `FromStr` impl
and the `ToJson` impl.

It also enables us to do further things with it like JSON schema
generation.
This schema is helpful for people writing custom target spec JSON. It
can provide autocomplete in the editor, and also serves as documentation
when there are documentation comments on the structs, as `schemars` will
put them in the schema.

@rustbot rustbot added S-waiting-on-review

Status: Awaiting review from the assignee but also interested parties.

and removed S-waiting-on-author

Status: This is awaiting some action (such as code changes or more information) from the author.

labels

Sep 12, 2025

jieyouxu

@bors bors added S-waiting-on-bors

Status: Waiting on bors to run and complete tests. Bors will change the label on completion.

and removed S-waiting-on-review

Status: Awaiting review from the assignee but also interested parties.

labels

Sep 13, 2025

bors added a commit that referenced this pull request

Sep 13, 2025
Rollup of 5 pull requests

Successful merges:

 - #144498 (Add --print target-spec-json-schema)
 - #145471 (Stabilize BTree{Map,Set}::extract_if)
 - #145896 (Rehome 30 `tests/ui/issues/` tests to other subdirectories under `tests/ui/` [#3 of Batch #2])
 - #146450 (bootstrap: rustdoc-js tests can now be filtered by js files)
 - #146456 (Fix panic and incorrectly suggested examples in `format_args` macro.)

r? `@ghost`
`@rustbot` modify labels: rollup

rust-timer added a commit that referenced this pull request

Sep 13, 2025
Rollup merge of #144498 - Noratrieb:rustc-json-schema, r=jieyouxu,davidtwco

Add --print target-spec-json-schema

This schema is helpful for people writing custom target spec JSON. It can provide autocomplete in the editor, and also serves as documentation when there are documentation comments on the structs, as `schemars` will put them in the schema.

I was motivated to do this because I saw someone write their own version of this schema by hand, so demand for this clearly exists. It's not a lot of effort to implement, so I thought it would make sense.

MCP: rust-lang/compiler-team#905

I think it would also be useful to put this in the sysroot in `etc` so people can link it directly in their editors.

I would have loved to add a test that validates the JSON schema against the spec JSON of every builtin target, but I don't want to do it as the JSON schema validation crates have incredible amounts of dependencies because JSON schema supports a ton of random features. I don't want to add that, even as a dev dependency.

github-actions bot pushed a commit to rust-lang/miri that referenced this pull request

Sep 14, 2025

oxalica added a commit to oxalica/rust-overlay that referenced this pull request

Sep 15, 2025

oxalica added a commit to oxalica/rust-overlay that referenced this pull request

Sep 15, 2025

yshui pushed a commit to yshui/rustup.nix that referenced this pull request

Dec 17, 2025

@ehuss ehuss mentioned this pull request

Jan 23, 2026

4 tasks