Skip to content

Conversation

Noratrieb
Copy link
Member

@Noratrieb Noratrieb commented Jul 26, 2025

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.

@rustbot 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
@rust-log-analyzer

This comment has been minimized.

@Noratrieb Noratrieb force-pushed the rustc-json-schema branch from 547cba8 to d6acb28 Compare July 26, 2025 22:15
@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
@rust-log-analyzer

This comment has been minimized.

@Noratrieb Noratrieb force-pushed the rustc-json-schema branch from d6acb28 to 8f1abd3 Compare July 27, 2025 11:33
@rust-log-analyzer

This comment has been minimized.

@Noratrieb Noratrieb force-pushed the rustc-json-schema branch from 8f1abd3 to a07cfd1 Compare July 27, 2025 12:18
@rust-log-analyzer

This comment has been minimized.

@Noratrieb Noratrieb force-pushed the rustc-json-schema branch from a07cfd1 to d4383c1 Compare July 27, 2025 13:42
@rustbot rustbot added the A-run-make Area: port run-make Makefiles to rmake.rs label Jul 27, 2025
@Noratrieb Noratrieb marked this pull request as ready for review July 27, 2025 17:52
@rustbot
Copy link
Collaborator

rustbot commented Jul 27, 2025

r? @fee1-dead

rustbot has assigned @fee1-dead.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@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
@rustbot
Copy link
Collaborator

rustbot commented Jul 27, 2025

Some changes occurred in compiler/rustc_codegen_ssa

cc @WaffleLapkin

The list of allowed third-party dependencies may have been modified! You must ensure that any new dependencies have compatible licenses before merging.

cc @davidtwco, @wesleywiser

These commits modify the Cargo.lock file. Unintentional changes to Cargo.lock can be introduced when switching branches and rebasing PRs.

If this was unintentional then you should revert the changes before this PR is merged.
Otherwise, you can ignore this comment.

These commits modify compiler targets.
(See the Target Tier Policy.)

This PR modifies run-make tests.

cc @jieyouxu

There are changes to the tidy tool.

cc @jieyouxu

@Noratrieb
Copy link
Member Author

Noratrieb commented Jul 27, 2025

The MCP isn't accepted yet, but that doesn't need to stop anyone from reviewing.
r? jieyouxu maybe you want to review it since it also touches bootstrap?

@rustbot rustbot assigned jieyouxu and unassigned fee1-dead Jul 27, 2025
@rustbot
Copy link
Collaborator

rustbot commented Jul 27, 2025

jieyouxu is currently at their maximum review capacity.
They may take a while to respond.

@jieyouxu
Copy link
Member

I can probably review it after the MCP passes.

Copy link
Member

@jieyouxu jieyouxu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, looks good to me overall, a few questions

@@ -361,6 +362,8 @@ const PERMITTED_RUSTC_DEPENDENCIES: &[&str] = &[
"rand_xorshift", // dependency for doc-tests in rustc_thread_pool
"rand_xoshiro",
"redox_syscall",
"ref-cast",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remark: at least this uses rustc version detection, not just nightly detection

https://github.com/dtolnay/ref-cast/blob/1.0.24/build.rs

@jieyouxu
Copy link
Member

None of them are blocking, so feel free to r=me once the MCP is accepted.

@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
@rust-log-analyzer

This comment has been minimized.

@rust-bors
Copy link

rust-bors bot commented Aug 11, 2025

☀️ Try build successful (CI)
Build commit: 2bfac14 (2bfac149c1d597d832231f56dadf7c09ef3195f8, parent: fce0e74720d199eb7839fdb51af35ac5226da178)

Copy link
Member

@davidtwco davidtwco left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Licenses of the new dependencies are good

Copy link
Member

@jieyouxu jieyouxu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, impl looks good too, r=me as well after fixing the lint problem

@jieyouxu jieyouxu removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Aug 14, 2025
@bors
Copy link
Collaborator

bors commented Aug 21, 2025

☔ The latest upstream changes (presumably #145701) made this pull request unmergeable. Please resolve the merge conflicts.

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
Copy link
Collaborator

rustbot commented Sep 12, 2025

This PR was rebased onto a different master commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

@Noratrieb
Copy link
Member Author

@rustbot ready
I finally managed to rebase, the range-diff is a bit confusing but it should work fine.

@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
Copy link
Member

@jieyouxu jieyouxu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jieyouxu
Copy link
Member

@bors r=jieyouxu,davidtwco

@bors
Copy link
Collaborator

bors commented Sep 13, 2025

📌 Commit f157ce9 has been approved by jieyouxu,davidtwco

It is now in the queue for this repository.

@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
@bors bors merged commit 5446444 into rust-lang:master Sep 13, 2025
10 checks passed
@rustbot rustbot added this to the 1.91.0 milestone Sep 13, 2025
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
Rollup of 5 pull requests

Successful merges:

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

r? `@ghost`
`@rustbot` modify labels: rollup
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-run-make Area: port run-make Makefiles to rmake.rs A-tidy Area: The tidy tool S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants