Skip to content

Commit d534704

Browse files
committed
Changelog #243
1 parent be7457f commit d534704

File tree

5 files changed

+171
-34
lines changed

5 files changed

+171
-34
lines changed

generated_assists.adoc

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1085,7 +1085,7 @@ fn ┃fun_name(n: i32) {
10851085

10861086
[discrete]
10871087
=== `extract_module`
1088-
**Source:** https://github.com/rust-lang/rust-analyzer/blob/master/crates/ide-assists/src/handlers/extract_module.rs#L30[extract_module.rs]
1088+
**Source:** https://github.com/rust-lang/rust-analyzer/blob/master/crates/ide-assists/src/handlers/extract_module.rs#L29[extract_module.rs]
10891089

10901090
Extracts a selected region as separate module. All the references, visibility and imports are
10911091
resolved.
@@ -1292,7 +1292,7 @@ fn foo<T: Copy + Clone>() { }
12921292

12931293
[discrete]
12941294
=== `generate_constant`
1295-
**Source:** https://github.com/rust-lang/rust-analyzer/blob/master/crates/ide-assists/src/handlers/generate_constant.rs#L13[generate_constant.rs]
1295+
**Source:** https://github.com/rust-lang/rust-analyzer/blob/master/crates/ide-assists/src/handlers/generate_constant.rs#L14[generate_constant.rs]
12961296

12971297
Generate a named constant.
12981298

@@ -1764,7 +1764,7 @@ impl From<u32> for A {
17641764

17651765
[discrete]
17661766
=== `generate_function`
1767-
**Source:** https://github.com/rust-lang/rust-analyzer/blob/master/crates/ide-assists/src/handlers/generate_function.rs#L29[generate_function.rs]
1767+
**Source:** https://github.com/rust-lang/rust-analyzer/blob/master/crates/ide-assists/src/handlers/generate_function.rs#L28[generate_function.rs]
17681768

17691769
Adds a stub function with a signature matching the function under the cursor.
17701770

@@ -2084,7 +2084,7 @@ impl<T: Clone> ${0:_} for Ctx<T> {}
20842084

20852085
[discrete]
20862086
=== `inline_call`
2087-
**Source:** https://github.com/rust-lang/rust-analyzer/blob/master/crates/ide-assists/src/handlers/inline_call.rs#L166[inline_call.rs]
2087+
**Source:** https://github.com/rust-lang/rust-analyzer/blob/master/crates/ide-assists/src/handlers/inline_call.rs#L165[inline_call.rs]
20882088

20892089
Inlines a function or method body creating a `let` statement per parameter unless the parameter
20902090
can be inlined. The parameter will be inlined either if it the supplied argument is a simple local
@@ -2135,7 +2135,7 @@ fn something() -> &'static str {
21352135

21362136
[discrete]
21372137
=== `inline_into_callers`
2138-
**Source:** https://github.com/rust-lang/rust-analyzer/blob/master/crates/ide-assists/src/handlers/inline_call.rs#L29[inline_call.rs]
2138+
**Source:** https://github.com/rust-lang/rust-analyzer/blob/master/crates/ide-assists/src/handlers/inline_call.rs#L28[inline_call.rs]
21392139

21402140
Inline a function or method body into all of its callers where possible, creating a `let` statement per parameter
21412141
unless the parameter can be inlined. The parameter will be inlined either if it the supplied argument is a simple local
@@ -2179,7 +2179,7 @@ fn bar() {
21792179

21802180
[discrete]
21812181
=== `inline_local_variable`
2182-
**Source:** https://github.com/rust-lang/rust-analyzer/blob/master/crates/ide-assists/src/handlers/inline_local_variable.rs#L18[inline_local_variable.rs]
2182+
**Source:** https://github.com/rust-lang/rust-analyzer/blob/master/crates/ide-assists/src/handlers/inline_local_variable.rs#L17[inline_local_variable.rs]
21832183

21842184
Inlines a local variable.
21852185

@@ -2946,7 +2946,7 @@ fn main() {
29462946

29472947
[discrete]
29482948
=== `remove_unused_imports`
2949-
**Source:** https://github.com/rust-lang/rust-analyzer/blob/master/crates/ide-assists/src/handlers/remove_unused_imports.rs#L15[remove_unused_imports.rs]
2949+
**Source:** https://github.com/rust-lang/rust-analyzer/blob/master/crates/ide-assists/src/handlers/remove_unused_imports.rs#L14[remove_unused_imports.rs]
29502950

29512951
Removes any use statements in the current selection that are unused.
29522952

@@ -3277,7 +3277,7 @@ fn handle(action: Action) {
32773277

32783278
[discrete]
32793279
=== `replace_named_generic_with_impl`
3280-
**Source:** https://github.com/rust-lang/rust-analyzer/blob/master/crates/ide-assists/src/handlers/replace_named_generic_with_impl.rs#L19[replace_named_generic_with_impl.rs]
3280+
**Source:** https://github.com/rust-lang/rust-analyzer/blob/master/crates/ide-assists/src/handlers/replace_named_generic_with_impl.rs#L18[replace_named_generic_with_impl.rs]
32813281

32823282
Replaces named generic with an `impl Trait` in function argument.
32833283

generated_config.adoc

Lines changed: 101 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ By default, a cargo invocation will be constructed for the configured
8282
targets and features, with the following base command line:
8383

8484
```bash
85-
cargo check --quiet --workspace --message-format=json --all-targets
85+
cargo check --quiet --workspace --message-format=json --all-targets --keep-going
8686
```
8787
.
8888
--
@@ -655,12 +655,12 @@ Whether to hide inlay hints for type adjustments outside of `unsafe` blocks.
655655
--
656656
Whether to show inlay hints as postfix ops (`.*` instead of `*`, etc).
657657
--
658-
[[rust-analyzer.inlayHints.genericParameterHints.const.enable]]rust-analyzer.inlayHints.genericParameterHints.const.enable (default: `false`)::
658+
[[rust-analyzer.inlayHints.genericParameterHints.const.enable]]rust-analyzer.inlayHints.genericParameterHints.const.enable (default: `true`)::
659659
+
660660
--
661661
Whether to show const generic parameter name inlay hints.
662662
--
663-
[[rust-analyzer.inlayHints.genericParameterHints.lifetime.enable]]rust-analyzer.inlayHints.genericParameterHints.lifetime.enable (default: `true`)::
663+
[[rust-analyzer.inlayHints.genericParameterHints.lifetime.enable]]rust-analyzer.inlayHints.genericParameterHints.lifetime.enable (default: `false`)::
664664
+
665665
--
666666
Whether to show generic lifetime parameter name inlay hints.
@@ -1015,6 +1015,104 @@ Show documentation.
10151015
--
10161016
Whether to insert closing angle brackets when typing an opening angle bracket of a generic argument list.
10171017
--
1018+
[[rust-analyzer.workspace.discoverConfig]]rust-analyzer.workspace.discoverConfig (default: `null`)::
1019+
+
1020+
--
1021+
Enables automatic discovery of projects using [`DiscoverWorkspaceConfig::command`].
1022+
1023+
[`DiscoverWorkspaceConfig`] also requires setting `progress_label` and `files_to_watch`.
1024+
`progress_label` is used for the title in progress indicators, whereas `files_to_watch`
1025+
is used to determine which build system-specific files should be watched in order to
1026+
reload rust-analyzer.
1027+
1028+
Below is an example of a valid configuration:
1029+
```json
1030+
"rust-analyzer.workspace.discoverConfig": {
1031+
"command": [
1032+
"rust-project",
1033+
"develop-json",
1034+
{arg}
1035+
],
1036+
"progressLabel": "rust-analyzer",
1037+
"filesToWatch": [
1038+
"BUCK",
1039+
],
1040+
}
1041+
```
1042+
1043+
## On `DiscoverWorkspaceConfig::command`
1044+
1045+
**Warning**: This format is provisional and subject to change.
1046+
1047+
[`DiscoverWorkspaceConfig::command`] *must* return a JSON object
1048+
corresponding to `DiscoverProjectData::Finished`:
1049+
1050+
```norun
1051+
#[derive(Debug, Clone, Deserialize, Serialize)]
1052+
#[serde(tag = "kind")]
1053+
#[serde(rename_all = "snake_case")]
1054+
enum DiscoverProjectData {
1055+
Finished { buildfile: Utf8PathBuf, project: ProjectJsonData },
1056+
Error { error: String, source: Option<String> },
1057+
Progress { message: String },
1058+
}
1059+
```
1060+
1061+
As JSON, `DiscoverProjectData::Finished` is:
1062+
1063+
```json
1064+
{
1065+
// the internally-tagged representation of the enum.
1066+
"kind": "finished",
1067+
// the file used by a non-Cargo build system to define
1068+
// a package or target.
1069+
"buildfile": "rust-analyzer/BUILD",
1070+
// the contents of a rust-project.json, elided for brevity
1071+
"project": {
1072+
"sysroot": "foo",
1073+
"crates": []
1074+
}
1075+
}
1076+
```
1077+
1078+
It is encouraged, but not required, to use the other variants on
1079+
`DiscoverProjectData` to provide a more polished end-user experience.
1080+
1081+
`DiscoverWorkspaceConfig::command` may *optionally* include an `{arg}`,
1082+
which will be substituted with the JSON-serialized form of the following
1083+
enum:
1084+
1085+
```norun
1086+
#[derive(PartialEq, Clone, Debug, Serialize)]
1087+
#[serde(rename_all = "camelCase")]
1088+
pub enum DiscoverArgument {
1089+
Path(AbsPathBuf),
1090+
Buildfile(AbsPathBuf),
1091+
}
1092+
```
1093+
1094+
The JSON representation of `DiscoverArgument::Path` is:
1095+
1096+
```json
1097+
{
1098+
"path": "src/main.rs"
1099+
}
1100+
```
1101+
1102+
Similarly, the JSON representation of `DiscoverArgument::Buildfile` is:
1103+
1104+
```
1105+
{
1106+
"buildfile": "BUILD"
1107+
}
1108+
```
1109+
1110+
`DiscoverArgument::Path` is used to find and generate a `rust-project.json`,
1111+
and therefore, a workspace, whereas `DiscoverArgument::buildfile` is used to
1112+
to update an existing workspace. As a reference for implementors,
1113+
buck2's `rust-project` will likely be useful:
1114+
https://github.com/facebook/buck2/tree/main/integrations/rust-project.
1115+
--
10181116
[[rust-analyzer.workspace.symbol.search.kind]]rust-analyzer.workspace.symbol.search.kind (default: `"only_types"`)::
10191117
+
10201118
--

generated_diagnostic.adoc

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ Only traits defined in the current crate can be implemented for arbitrary types
170170

171171

172172
=== trait-impl-redundant-assoc_item
173-
**Source:** https://github.com/rust-lang/rust-analyzer/blob/master/crates/ide-diagnostics/src/handlers/trait_impl_redundant_assoc_item.rs#L11[trait_impl_redundant_assoc_item.rs]
173+
**Source:** https://github.com/rust-lang/rust-analyzer/blob/master/crates/ide-diagnostics/src/handlers/trait_impl_redundant_assoc_item.rs#L12[trait_impl_redundant_assoc_item.rs]
174174

175175
Diagnoses redundant trait items in a trait impl.
176176

@@ -207,7 +207,7 @@ crates rust-analyzer failed to discover. The file will not have IDE features ava
207207

208208

209209
=== unnecessary-braces
210-
**Source:** https://github.com/rust-lang/rust-analyzer/blob/master/crates/ide-diagnostics/src/handlers/useless_braces.rs#L12[useless_braces.rs]
210+
**Source:** https://github.com/rust-lang/rust-analyzer/blob/master/crates/ide-diagnostics/src/handlers/useless_braces.rs#L9[useless_braces.rs]
211211

212212
Diagnostic for unnecessary braces in `use` items.
213213

@@ -230,7 +230,7 @@ This diagnostic is triggered if rust-analyzer is unable to discover referred ext
230230

231231

232232
=== unresolved-field
233-
**Source:** https://github.com/rust-lang/rust-analyzer/blob/master/crates/ide-diagnostics/src/handlers/unresolved_field.rs#L24[unresolved_field.rs]
233+
**Source:** https://github.com/rust-lang/rust-analyzer/blob/master/crates/ide-diagnostics/src/handlers/unresolved_field.rs#L23[unresolved_field.rs]
234234

235235
This diagnostic is triggered if a field does not exist on a given type.
236236

@@ -256,7 +256,7 @@ to a macro in a macro invocation.
256256

257257

258258
=== unresolved-method
259-
**Source:** https://github.com/rust-lang/rust-analyzer/blob/master/crates/ide-diagnostics/src/handlers/unresolved_method.rs#L16[unresolved_method.rs]
259+
**Source:** https://github.com/rust-lang/rust-analyzer/blob/master/crates/ide-diagnostics/src/handlers/unresolved_method.rs#L15[unresolved_method.rs]
260260

261261
This diagnostic is triggered if a method does not exist on a given type.
262262

@@ -286,6 +286,6 @@ This diagnostic is triggered when a mutable variable isn't actually mutated.
286286

287287

288288
=== unused-variables
289-
**Source:** https://github.com/rust-lang/rust-analyzer/blob/master/crates/ide-diagnostics/src/handlers/unused_variables.rs#L14[unused_variables.rs]
289+
**Source:** https://github.com/rust-lang/rust-analyzer/blob/master/crates/ide-diagnostics/src/handlers/unused_variables.rs#L13[unused_variables.rs]
290290

291291
This diagnostic is triggered when a local variable is not used.

0 commit comments

Comments
 (0)