diff options
| author | bors <bors@rust-lang.org> | 2025-09-13 10:43:09 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2025-09-13 10:43:09 +0000 |
| commit | b50f345a2f3f49764024cabc30ef99e15c0240f7 (patch) | |
| tree | 542d89dfb423203f19a9ce2345be87bb2ef7f0cb /compiler/rustc_target/src/spec/json.rs | |
| parent | 064cc81354a940e297a1be4dfa9e26759c8431be (diff) | |
| parent | c4539b2d58d97093fc08a42561397fa98e75c684 (diff) | |
| download | rust-b50f345a2f3f49764024cabc30ef99e15c0240f7.tar.gz rust-b50f345a2f3f49764024cabc30ef99e15c0240f7.zip | |
Auto merge of #146499 - jhpratt:rollup-ufflehe, r=jhpratt
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
Diffstat (limited to 'compiler/rustc_target/src/spec/json.rs')
| -rw-r--r-- | compiler/rustc_target/src/spec/json.rs | 38 |
1 files changed, 34 insertions, 4 deletions
diff --git a/compiler/rustc_target/src/spec/json.rs b/compiler/rustc_target/src/spec/json.rs index e9ae5734d5b..f236be92b3b 100644 --- a/compiler/rustc_target/src/spec/json.rs +++ b/compiler/rustc_target/src/spec/json.rs @@ -408,12 +408,12 @@ impl ToJson for Target { } } -#[derive(serde_derive::Deserialize)] +#[derive(serde_derive::Deserialize, schemars::JsonSchema)] struct LinkSelfContainedComponentsWrapper { components: Vec<LinkSelfContainedComponents>, } -#[derive(serde_derive::Deserialize)] +#[derive(serde_derive::Deserialize, schemars::JsonSchema)] #[serde(untagged)] enum TargetFamiliesJson { Array(StaticCow<[StaticCow<str>]>), @@ -429,6 +429,18 @@ impl FromStr for EndianWrapper { } } crate::json::serde_deserialize_from_str!(EndianWrapper); +impl schemars::JsonSchema for EndianWrapper { + fn schema_name() -> std::borrow::Cow<'static, str> { + "Endian".into() + } + fn json_schema(_: &mut schemars::SchemaGenerator) -> schemars::Schema { + schemars::json_schema! ({ + "type": "string", + "enum": ["big", "little"] + }) + .into() + } +} /// `ExternAbi` is in `rustc_abi`, which doesn't have access to the macro and serde. struct ExternAbiWrapper(rustc_abi::ExternAbi); @@ -441,8 +453,22 @@ impl FromStr for ExternAbiWrapper { } } crate::json::serde_deserialize_from_str!(ExternAbiWrapper); +impl schemars::JsonSchema for ExternAbiWrapper { + fn schema_name() -> std::borrow::Cow<'static, str> { + "ExternAbi".into() + } + fn json_schema(_: &mut schemars::SchemaGenerator) -> schemars::Schema { + let all = + rustc_abi::ExternAbi::ALL_VARIANTS.iter().map(|abi| abi.as_str()).collect::<Vec<_>>(); + schemars::json_schema! ({ + "type": "string", + "enum": all, + }) + .into() + } +} -#[derive(serde_derive::Deserialize)] +#[derive(serde_derive::Deserialize, schemars::JsonSchema)] struct TargetSpecJsonMetadata { description: Option<StaticCow<str>>, tier: Option<u64>, @@ -450,7 +476,7 @@ struct TargetSpecJsonMetadata { std: Option<bool>, } -#[derive(serde_derive::Deserialize)] +#[derive(serde_derive::Deserialize, schemars::JsonSchema)] #[serde(rename_all = "kebab-case")] // Ensure that all unexpected fields get turned into errors. // This helps users stay up to date when the schema changes instead of silently @@ -593,3 +619,7 @@ struct TargetSpecJson { supports_xray: Option<bool>, entry_abi: Option<ExternAbiWrapper>, } + +pub fn json_schema() -> schemars::Schema { + schemars::schema_for!(TargetSpecJson) +} |
