Skip to content

Commit

Permalink
Support lints in Cargo schema (#4336)
Browse files Browse the repository at this point in the history
  • Loading branch information
uncenter authored Jan 7, 2025
1 parent 5a02676 commit 7c91a8e
Showing 1 changed file with 100 additions and 0 deletions.
100 changes: 100 additions & 0 deletions src/schemas/json/cargo.json
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,24 @@
"initFields": ["version"]
}
},
"DetailedLint": {
"title": "Detailed Lint",
"type": "object",
"properties": {
"level": {
"$ref": "#/definitions/LintLevel"
},
"priority": {
"description": "The priority that controls which lints or [lint groups](https://doc.rust-lang.org/rustc/lints/groups.html) override other lint groups. Lower (particularly negative) numbers have lower priority, being overridden by higher numbers, and show up first on the command-line to tools like rustc.",
"type": "integer",
"x-taplo": {
"links": {
"key": "https://doc.rust-lang.org/stable/cargo/reference/manifest.html#the-lints-section"
}
}
}
}
},
"Edition": {
"title": "Edition",
"description": "The `edition` key affects which edition your package is compiled with. Cargo\nwill always generate packages via [`cargo new`](https://doc.rust-lang.org/cargo/commands/cargo-new.html) with the `edition` key set to the\nlatest edition. Setting the `edition` key in `[package]` will affect all\ntargets/crates in the package, including test suites, benchmarks, binaries,\nexamples, etc.",
Expand All @@ -229,6 +247,56 @@
}
}
},
"Lint": {
"title": "Lint",
"anyOf": [
{
"$ref": "#/definitions/LintLevel"
},
{
"$ref": "#/definitions/DetailedLint"
}
]
},
"LintLevel": {
"title": "Lint Level",
"description": "Specify the [lint level](https://doc.rust-lang.org/rustc/lints/levels.html) for a lint or lint group.",
"type": "string",
"enum": ["forbid", "deny", "warn", "allow"],
"x-taplo": {
"docs": {
"enumValues": [
"`forbid` is the same as `deny` in that a lint at this level will produce an error, but unlike the `deny` level, the `forbid` level can not be overridden to be anything lower than an error. However, lint levels may still be capped with [`--cap-lints`](https://doc.rust-lang.org/rustc/lints/levels.html#capping-lints) so `rustc --cap-lints warn` will make lints set to `forbid` just warn.",
"The `deny` lint level produces an error if you violate the lint.",
"The `warn` lint level produces a warning if you violate the lint.",
"The `allow` lint level ignores violations of the lint."
]
},
"links": {
"key": "https://doc.rust-lang.org/rustc/lints/levels.html"
}
}
},
"Lints": {
"type": "object",
"properties": {
"clippy": {
"description": "Lint settings for [Clippy](https://doc.rust-lang.org/clippy/). See Clippy's [individual lints](https://rust-lang.github.io/rust-clippy/master/index.html) or [lint groups](https://doc.rust-lang.org/clippy/lints.html) documentation.",
"type": "object",
"additionalProperties": {
"$ref": "#/definitions/Lint"
}
},
"rust": {
"description": "Lint settings for the Rust compiler. See the Rust compiler's [individual lints](https://doc.rust-lang.org/rustc/lints/listing/index.html) or [lint groups](https://doc.rust-lang.org/rustc/lints/groups.html).",
"type": "object",
"additionalProperties": {
"$ref": "#/definitions/Lint"
}
}
},
"additionalProperties": false
},
"Lto": {
"title": "Lto",
"description": "The `lto` setting controls the [`-C lto` flag](https://doc.rust-lang.org/rustc/codegen-options/index.html#lto) which controls LLVM's [link time optimizations](https://llvm.org/docs/LinkTimeOptimization.html). LTO can produce better optimized code, using\nwhole-program analysis, at the cost of longer linking time.\n \nSee also the [`-C linker-plugin-lto`](https://doc.rust-lang.org/rustc/codegen-options/index.html#linker-plugin-lto) `rustc` flag for cross-language LTO.",
Expand Down Expand Up @@ -1114,6 +1182,15 @@
}
}
},
"lints": {
"$ref": "#/definitions/Lints",
"description": "The `workspace.lints` table is where you define lint configuration to be inherited by members of a workspace.",
"x-taplo": {
"links": {
"key": "https://doc.rust-lang.org/cargo/reference/workspaces.html#the-workspace-section"
}
}
},
"members": {
"description": "All [`path` dependencies] residing in the workspace directory automatically\nbecome members. Additional members can be listed with the `members` key, which\nshould be an array of strings containing directories with `Cargo.toml` files.\n\nThe `members` list also supports [globs] to match multiple paths, using\ntypical filename glob patterns like `*` and `?`.",
"type": "array",
Expand Down Expand Up @@ -1782,6 +1859,29 @@
}
}
},
"lints": {
"description": "Override the default level of lints from different tools by assigning them to a new level in a table.",
"anyOf": [
{
"$ref": "#/definitions/Lints"
},
{
"type": "object",
"properties": {
"workspace": {
"type": "boolean",
"description": "Inherit lints from the workspace manifest."
}
},
"additionalProperties": false
}
],
"x-taplo": {
"links": {
"key": "https://doc.rust-lang.org/stable/cargo/reference/manifest.html#the-lints-section"
}
}
},
"package": {
"$ref": "#/definitions/Package"
},
Expand Down

0 comments on commit 7c91a8e

Please sign in to comment.