Skip to content

Commit 4c6e804

Browse files
Merge pull request #20358 from iorizu/issue-20346
minor: Fix documentation for `*.overrideCommand` config options
2 parents 7c60865 + 7d16726 commit 4c6e804

File tree

4 files changed

+29
-13
lines changed

4 files changed

+29
-13
lines changed

src/tools/rust-analyzer/crates/rust-analyzer/src/config.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -726,7 +726,9 @@ config_data! {
726726
/// ```bash
727727
/// cargo check --quiet --workspace --message-format=json --all-targets --keep-going
728728
/// ```
729-
/// .
729+
///
730+
/// Note: The option must be specified as an array of command line arguments, with
731+
/// the first argument being the name of the command to run.
730732
cargo_buildScripts_overrideCommand: Option<Vec<String>> = None,
731733
/// Rerun proc-macros building/build-scripts running when proc-macro
732734
/// or build-script sources change and are saved.
@@ -840,7 +842,9 @@ config_data! {
840842
/// ```bash
841843
/// cargo check --workspace --message-format=json --all-targets
842844
/// ```
843-
/// .
845+
///
846+
/// Note: The option must be specified as an array of command line arguments, with
847+
/// the first argument being the name of the command to run.
844848
check_overrideCommand | checkOnSave_overrideCommand: Option<Vec<String>> = None,
845849
/// Check for specific targets. Defaults to `#rust-analyzer.cargo.target#` if empty.
846850
///
@@ -890,6 +894,9 @@ config_data! {
890894
/// not that of `cargo fmt`. The file contents will be passed on the
891895
/// standard input and the formatted result will be read from the
892896
/// standard output.
897+
///
898+
/// Note: The option must be specified as an array of command line arguments, with
899+
/// the first argument being the name of the command to run.
893900
rustfmt_overrideCommand: Option<Vec<String>> = None,
894901
/// Enables the use of rustfmt's unstable range formatting command for the
895902
/// `textDocument/rangeFormatting` request. The rustfmt option is unstable and only

src/tools/rust-analyzer/docs/book/src/configuration_generated.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,9 @@ targets and features, with the following base command line:
104104
```bash
105105
cargo check --quiet --workspace --message-format=json --all-targets --keep-going
106106
```
107-
.
107+
108+
Note: The option must be specified as an array of command line arguments, with
109+
the first argument being the name of the command to run.
108110

109111

110112
## rust-analyzer.cargo.buildScripts.rebuildOnSave {#cargo.buildScripts.rebuildOnSave}
@@ -331,7 +333,9 @@ An example command would be:
331333
```bash
332334
cargo check --workspace --message-format=json --all-targets
333335
```
334-
.
336+
337+
Note: The option must be specified as an array of command line arguments, with
338+
the first argument being the name of the command to run.
335339

336340

337341
## rust-analyzer.check.targets {#check.targets}
@@ -1343,6 +1347,9 @@ not that of `cargo fmt`. The file contents will be passed on the
13431347
standard input and the formatted result will be read from the
13441348
standard output.
13451349

1350+
Note: The option must be specified as an array of command line arguments, with
1351+
the first argument being the name of the command to run.
1352+
13461353

13471354
## rust-analyzer.rustfmt.rangeFormatting.enable {#rustfmt.rangeFormatting.enable}
13481355

src/tools/rust-analyzer/docs/book/src/contributing/style.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ In this case, we'll probably ask you to split API changes into a separate PR.
4949
Changes of the third group should be pretty rare, so we don't specify any specific process for them.
5050
That said, adding an innocent-looking `pub use` is a very simple way to break encapsulation, keep an eye on it!
5151

52-
Note: if you enjoyed this abstract hand-waving about boundaries, you might appreciate
53-
https://www.tedinski.com/2018/02/06/system-boundaries.html
52+
Note: if you enjoyed this abstract hand-waving about boundaries, you might appreciate [this post](https://www.tedinski.com/2018/02/06/system-boundaries.html).
53+
5454

5555
## Crates.io Dependencies
5656

@@ -231,7 +231,7 @@ fn is_string_literal(s: &str) -> bool {
231231
}
232232
```
233233

234-
In the "Not as good" version, the precondition that `1` is a valid char boundary is checked in `is_string_literal` and used in `foo`.
234+
In the "Bad" version, the precondition that `1` and `s.len() - 1` are valid string literal boundaries is checked in `is_string_literal` but used in `main`.
235235
In the "Good" version, the precondition check and usage are checked in the same block, and then encoded in the types.
236236

237237
**Rationale:** non-local code properties degrade under change.
@@ -271,6 +271,8 @@ fn f() {
271271
}
272272
```
273273

274+
See also [this post](https://matklad.github.io/2023/11/15/push-ifs-up-and-fors-down.html)
275+
274276
## Assertions
275277

276278
Assert liberally.
@@ -608,15 +610,15 @@ Avoid making a lot of code type parametric, *especially* on the boundaries betwe
608610

609611
```rust
610612
// GOOD
611-
fn frobnicate(f: impl FnMut()) {
613+
fn frobnicate(mut f: impl FnMut()) {
612614
frobnicate_impl(&mut f)
613615
}
614616
fn frobnicate_impl(f: &mut dyn FnMut()) {
615617
// lots of code
616618
}
617619

618620
// BAD
619-
fn frobnicate(f: impl FnMut()) {
621+
fn frobnicate(mut f: impl FnMut()) {
620622
// lots of code
621623
}
622624
```
@@ -975,7 +977,7 @@ Don't use the `ref` keyword.
975977
**Rationale:** consistency & simplicity.
976978
`ref` was required before [match ergonomics](https://github.com/rust-lang/rfcs/blob/master/text/2005-match-ergonomics.md).
977979
Today, it is redundant.
978-
Between `ref` and mach ergonomics, the latter is more ergonomic in most cases, and is simpler (does not require a keyword).
980+
Between `ref` and match ergonomics, the latter is more ergonomic in most cases, and is simpler (does not require a keyword).
979981

980982
## Empty Match Arms
981983

src/tools/rust-analyzer/editors/code/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -887,7 +887,7 @@
887887
"title": "Cargo",
888888
"properties": {
889889
"rust-analyzer.cargo.buildScripts.overrideCommand": {
890-
"markdownDescription": "Override the command rust-analyzer uses to run build scripts and\nbuild procedural macros. The command is required to output json\nand should therefore include `--message-format=json` or a similar\noption.\n\nIf there are multiple linked projects/workspaces, this command is invoked for\neach of them, with the working directory being the workspace root\n(i.e., the folder containing the `Cargo.toml`). This can be overwritten\nby changing `#rust-analyzer.cargo.buildScripts.invocationStrategy#`.\n\nBy default, a cargo invocation will be constructed for the configured\ntargets and features, with the following base command line:\n\n```bash\ncargo check --quiet --workspace --message-format=json --all-targets --keep-going\n```\n.",
890+
"markdownDescription": "Override the command rust-analyzer uses to run build scripts and\nbuild procedural macros. The command is required to output json\nand should therefore include `--message-format=json` or a similar\noption.\n\nIf there are multiple linked projects/workspaces, this command is invoked for\neach of them, with the working directory being the workspace root\n(i.e., the folder containing the `Cargo.toml`). This can be overwritten\nby changing `#rust-analyzer.cargo.buildScripts.invocationStrategy#`.\n\nBy default, a cargo invocation will be constructed for the configured\ntargets and features, with the following base command line:\n\n```bash\ncargo check --quiet --workspace --message-format=json --all-targets --keep-going\n```\n\nNote: The option must be specified as an array of command line arguments, with\nthe first argument being the name of the command to run.",
891891
"default": null,
892892
"type": [
893893
"null",
@@ -1207,7 +1207,7 @@
12071207
"title": "Check",
12081208
"properties": {
12091209
"rust-analyzer.check.overrideCommand": {
1210-
"markdownDescription": "Override the command rust-analyzer uses instead of `cargo check` for\ndiagnostics on save. The command is required to output json and\nshould therefore include `--message-format=json` or a similar option\n(if your client supports the `colorDiagnosticOutput` experimental\ncapability, you can use `--message-format=json-diagnostic-rendered-ansi`).\n\nIf you're changing this because you're using some tool wrapping\nCargo, you might also want to change\n`#rust-analyzer.cargo.buildScripts.overrideCommand#`.\n\nIf there are multiple linked projects/workspaces, this command is invoked for\neach of them, with the working directory being the workspace root\n(i.e., the folder containing the `Cargo.toml`). This can be overwritten\nby changing `#rust-analyzer.check.invocationStrategy#`.\n\nIf `$saved_file` is part of the command, rust-analyzer will pass\nthe absolute path of the saved file to the provided command. This is\nintended to be used with non-Cargo build systems.\nNote that `$saved_file` is experimental and may be removed in the future.\n\nAn example command would be:\n\n```bash\ncargo check --workspace --message-format=json --all-targets\n```\n.",
1210+
"markdownDescription": "Override the command rust-analyzer uses instead of `cargo check` for\ndiagnostics on save. The command is required to output json and\nshould therefore include `--message-format=json` or a similar option\n(if your client supports the `colorDiagnosticOutput` experimental\ncapability, you can use `--message-format=json-diagnostic-rendered-ansi`).\n\nIf you're changing this because you're using some tool wrapping\nCargo, you might also want to change\n`#rust-analyzer.cargo.buildScripts.overrideCommand#`.\n\nIf there are multiple linked projects/workspaces, this command is invoked for\neach of them, with the working directory being the workspace root\n(i.e., the folder containing the `Cargo.toml`). This can be overwritten\nby changing `#rust-analyzer.check.invocationStrategy#`.\n\nIf `$saved_file` is part of the command, rust-analyzer will pass\nthe absolute path of the saved file to the provided command. This is\nintended to be used with non-Cargo build systems.\nNote that `$saved_file` is experimental and may be removed in the future.\n\nAn example command would be:\n\n```bash\ncargo check --workspace --message-format=json --all-targets\n```\n\nNote: The option must be specified as an array of command line arguments, with\nthe first argument being the name of the command to run.",
12111211
"default": null,
12121212
"type": [
12131213
"null",
@@ -2808,7 +2808,7 @@
28082808
"title": "Rustfmt",
28092809
"properties": {
28102810
"rust-analyzer.rustfmt.overrideCommand": {
2811-
"markdownDescription": "Advanced option, fully override the command rust-analyzer uses for\nformatting. This should be the equivalent of `rustfmt` here, and\nnot that of `cargo fmt`. The file contents will be passed on the\nstandard input and the formatted result will be read from the\nstandard output.",
2811+
"markdownDescription": "Advanced option, fully override the command rust-analyzer uses for\nformatting. This should be the equivalent of `rustfmt` here, and\nnot that of `cargo fmt`. The file contents will be passed on the\nstandard input and the formatted result will be read from the\nstandard output.\n\nNote: The option must be specified as an array of command line arguments, with\nthe first argument being the name of the command to run.",
28122812
"default": null,
28132813
"type": [
28142814
"null",

0 commit comments

Comments
 (0)