Skip to content

Commit 0d0470f

Browse files
authored
Merge pull request #86 from rust-analyzer/changelog-64
Changelog #64
2 parents 8a57b0a + 7ccb6d5 commit 0d0470f

File tree

6 files changed

+257
-12
lines changed

6 files changed

+257
-12
lines changed

generated_assists.adoc

Lines changed: 87 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -595,7 +595,7 @@ enum A { One(u32) }
595595

596596
impl From<u32> for A {
597597
fn from(v: u32) -> Self {
598-
A::One(v)
598+
Self::One(v)
599599
}
600600
}
601601
```
@@ -632,9 +632,65 @@ fn bar(arg: &str, baz: Baz) ${0:-> ()} {
632632
```
633633

634634

635+
[discrete]
636+
=== `generate_getter`
637+
**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/assists/src/handlers/generate_getter.rs#L9[generate_getter.rs]
638+
639+
Generate a getter method.
640+
641+
.Before
642+
```rust
643+
struct Person {
644+
nam┃e: String,
645+
}
646+
```
647+
648+
.After
649+
```rust
650+
struct Person {
651+
name: String,
652+
}
653+
654+
impl Person {
655+
/// Get a reference to the person's name.
656+
fn name(&self) -> &String {
657+
&self.name
658+
}
659+
}
660+
```
661+
662+
663+
[discrete]
664+
=== `generate_getter_mut`
665+
**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/assists/src/handlers/generate_getter_mut.rs#L9[generate_getter_mut.rs]
666+
667+
Generate a mut getter method.
668+
669+
.Before
670+
```rust
671+
struct Person {
672+
nam┃e: String,
673+
}
674+
```
675+
676+
.After
677+
```rust
678+
struct Person {
679+
name: String,
680+
}
681+
682+
impl Person {
683+
/// Get a mutable reference to the person's name.
684+
fn name_mut(&mut self) -> &mut String {
685+
&mut self.name
686+
}
687+
}
688+
```
689+
690+
635691
[discrete]
636692
=== `generate_impl`
637-
**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/assists/src/handlers/generate_impl.rs#L10[generate_impl.rs]
693+
**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/assists/src/handlers/generate_impl.rs#L5[generate_impl.rs]
638694

639695
Adds a new inherent impl for a type.
640696

@@ -659,7 +715,7 @@ impl<T: Clone> Ctx<T> {
659715

660716
[discrete]
661717
=== `generate_new`
662-
**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/assists/src/handlers/generate_new.rs#L13[generate_new.rs]
718+
**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/assists/src/handlers/generate_new.rs#L11[generate_new.rs]
663719

664720
Adds a new inherent impl for a type.
665721

@@ -679,7 +735,34 @@ struct Ctx<T: Clone> {
679735
impl<T: Clone> Ctx<T> {
680736
fn ┃new(data: T) -> Self { Self { data } }
681737
}
738+
```
739+
740+
741+
[discrete]
742+
=== `generate_setter`
743+
**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/assists/src/handlers/generate_setter.rs#L9[generate_setter.rs]
682744

745+
Generate a setter method.
746+
747+
.Before
748+
```rust
749+
struct Person {
750+
nam┃e: String,
751+
}
752+
```
753+
754+
.After
755+
```rust
756+
struct Person {
757+
name: String,
758+
}
759+
760+
impl Person {
761+
/// Set the person's name.
762+
fn set_name(&mut self, name: String) {
763+
self.name = name;
764+
}
765+
}
683766
```
684767

685768

@@ -730,7 +813,7 @@ fn main() {
730813

731814
[discrete]
732815
=== `inline_local_variable`
733-
**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/assists/src/handlers/inline_local_variable.rs#L16[inline_local_variable.rs]
816+
**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/assists/src/handlers/inline_local_variable.rs#L14[inline_local_variable.rs]
734817

735818
Inlines local variable.
736819

generated_config.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@
105105
[[rust-analyzer.runnables.cargoExtraArgs]]rust-analyzer.runnables.cargoExtraArgs (default: `[]`)::
106106
Additional arguments to be passed to cargo for runnables such as tests or binaries.\nFor example, it may be `--release`.
107107
[[rust-analyzer.rustcSource]]rust-analyzer.rustcSource (default: `null`)::
108-
Path to the rust compiler sources, for usage in rustc_private projects.
108+
Path to the rust compiler sources, for usage in rustc_private projects, or "discover" to try to automatically find it.
109109
[[rust-analyzer.rustfmt.extraArgs]]rust-analyzer.rustfmt.extraArgs (default: `[]`)::
110110
Additional arguments to `rustfmt`.
111111
[[rust-analyzer.rustfmt.overrideCommand]]rust-analyzer.rustfmt.overrideCommand (default: `null`)::

generated_diagnostic.adoc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ This diagnostic is shown for code with inactive `#[cfg]` attributes.
1212

1313

1414
=== incorrect-ident-case
15-
**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/hir_ty/src/diagnostics.rs#L348[diagnostics.rs]
15+
**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/hir_ty/src/diagnostics.rs#L379[diagnostics.rs]
1616

1717
This diagnostic is triggered if an item name doesn't follow https://doc.rust-lang.org/1.0.0/style/style/naming/README.html[Rust naming convention].
1818

@@ -95,7 +95,7 @@ This diagnostic is triggered if created structure does not have field provided i
9595

9696

9797
=== replace-filter-map-next-with-find-map
98-
**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/hir_ty/src/diagnostics.rs#L389[diagnostics.rs]
98+
**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/hir_ty/src/diagnostics.rs#L420[diagnostics.rs]
9999

100100
This diagnostic is triggered when `.filter_map(..).next()` is used, rather than the more concise `.find_map(..)`.
101101

generated_features.adoc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
11
//Generated file, do not edit by hand, see `xtask/src/codegen`
2+
=== Annotations
3+
**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ide/src/annotations.rs#L17[annotations.rs]
4+
5+
Provides user with annotations above items for looking up references or impl blocks
6+
and running/debugging binaries.
7+
8+
29
=== Auto Import
310
**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/assists/src/handlers/auto_import.rs#L10[auto_import.rs]
411

manual.adoc

Lines changed: 85 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,8 @@ $ pacman -S rust-analyzer
194194

195195
=== Emacs
196196

197+
Note this excellent https://robert.kra.hn/posts/2021-02-07_rust-with-emacs/[guide] from https://github.com/rksm[@rksm].
198+
197199
Prerequisites: You have installed the <<rust-analyzer-language-server-binary,`rust-analyzer` binary>>.
198200

199201
Emacs support is maintained as part of the https://github.com/emacs-lsp/lsp-mode[Emacs-LSP] package in https://github.com/emacs-lsp/lsp-mode/blob/master/lsp-rust.el[lsp-rust.el].
@@ -307,6 +309,52 @@ EOF
307309

308310
See https://sharksforarms.dev/posts/neovim-rust/ for more tips on getting started.
309311

312+
==== vim-lsp
313+
314+
vim-lsp is installed by following https://github.com/prabirshrestha/vim-lsp[the plugin instructions].
315+
It can be as simple as adding this line to your `.vimrc`:
316+
317+
[source,vim]
318+
----
319+
Plug 'prabirshrestha/vim-lsp'
320+
----
321+
322+
Next you need to register the `rust-analyzer` binary.
323+
If it is available in `$PATH`, you may want to add this to your `.vimrc`:
324+
325+
[source,vim]
326+
----
327+
if executable('rust-analyzer')
328+
au User lsp_setup call lsp#register_server({
329+
\ 'name': 'Rust Language Server',
330+
\ 'cmd': {server_info->['rust-analyzer']},
331+
\ 'whitelist': ['rust'],
332+
\ })
333+
endif
334+
----
335+
336+
There is no dedicated UI for the server configuration, so you would need to send any options as a value of the `initialization_options` field, as described in the <<_configuration,Configuration>> section.
337+
Here is an example of how to enable the proc-macro support:
338+
339+
[source,vim]
340+
----
341+
if executable('rust-analyzer')
342+
au User lsp_setup call lsp#register_server({
343+
\ 'name': 'Rust Language Server',
344+
\ 'cmd': {server_info->['rust-analyzer']},
345+
\ 'whitelist': ['rust'],
346+
\ 'initialization_options': {
347+
\ 'cargo': {
348+
\ 'loadOutDirsFromCheck': v:true,
349+
\ },
350+
\ 'procMacro': {
351+
\ 'enable': v:true,
352+
\ },
353+
\ },
354+
\ })
355+
endif
356+
----
357+
310358
=== Sublime Text 3
311359

312360
Prerequisites: You have installed the <<rust-analyzer-language-server-binary,`rust-analyzer` binary>>.
@@ -331,17 +379,49 @@ If you get an error saying `No such file or directory: 'rust-analyzer'`, see the
331379
GNOME Builder 3.37.1 and newer has native `rust-analyzer` support.
332380
If the LSP binary is not available, GNOME Builder can install it when opening a Rust file.
333381

382+
383+
=== Eclipse IDE
384+
385+
Prerequisites: You have installed the <<rust-analyzer-language-server-binary,`rust-analyzer` binary>>.
386+
387+
Support for Rust development in the Eclipse IDE is provided by link:https://github.com/eclipse/corrosion[Eclipse Corrosion].
388+
While it currently uses RLS as default, you can successfully configure it so the IDE will use `rust-analyzer` instead.
389+
To do so, with an Eclipse IDE where Corrosion is installed, just go to __Window > Preferences > Rust__ and edit the __Path to Rust Language Server__ entry to reference the path to `rust-analyzer`.
390+
You'll need to close and reopen all .rs and Cargo files, or to restart the IDE, for this change to take effect.
391+
334392
== Configuration
335393

336394
**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/rust-analyzer/src/config.rs[config.rs]
337395

338-
rust-analyzer is configured via LSP messages, which means that it's up to the editor to decide on the exact format and location of configuration files.
339-
Please consult your editor's documentation to learn how to configure LSP servers.
396+
The <<_installation,Installation>> section contains details on configuration for some of the editors.
397+
In general `rust-analyzer` is configured via LSP messages, which means that it's up to the editor to decide on the exact format and location of configuration files.
398+
399+
Some clients, such as <<vs-code,VS Code>> or <<coc-rust-analyzer,COC plugin in Vim>> provide `rust-analyzer` specific configuration UIs. Others may require you to know a bit more about the interaction with `rust-analyzer`.
400+
401+
For the later category, it might help to know that the initial configuration is specified as a value of the `intializationOptions` field of the https://microsoft.github.io/language-server-protocol/specifications/specification-current/#initialize[`InitializeParams` message, in the LSP protocol].
402+
The spec says that the field type is `any?`, but `rust-analyzer` is looking for a JSON object that is constructed using settings from the list below.
403+
Name of the setting, ignoring the `rust-analyzer.` prefix, is used as a path, and value of the setting becomes the JSON property value.
404+
405+
For example, a very common configuration is to enable proc-macro support, can be achieved by sending this JSON:
406+
407+
[source,json]
408+
----
409+
{
410+
"cargo": {
411+
"loadOutDirsFromCheck": true,
412+
},
413+
"procMacro": {
414+
"enable": true,
415+
}
416+
}
417+
----
418+
419+
Please consult your editor's documentation to learn more about how to configure https://microsoft.github.io/language-server-protocol/[LSP servers].
340420

341-
To verify which configuration is actually used by rust-analyzer, set `RA_LOG` environment variable to `rust_analyzer=info` and look for config-related messages.
342-
Logs should show both the JSON that rust-analyzer sees as well as the updated config.
421+
To verify which configuration is actually used by `rust-analyzer`, set `RA_LOG` environment variable to `rust_analyzer=info` and look for config-related messages.
422+
Logs should show both the JSON that `rust-analyzer` sees as well as the updated config.
343423

344-
This is the list of config options rust-analyzer supports:
424+
This is the list of config options `rust-analyzer` supports:
345425

346426
include::./generated_config.adoc[]
347427

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
= Changelog #66
2+
:sectanchors:
3+
:page-layout: post
4+
5+
Commit: commit:7435b9e98c9280043605748c11a1f450669e04d6[] +
6+
Release: release:2021-02-15[]
7+
8+
== Sponsors
9+
10+
**Become a sponsor:** On https://opencollective.com/rust-analyzer/[OpenCollective] or
11+
https://github.com/sponsors/rust-analyzer[GitHub Sponsors].
12+
13+
== New Features
14+
15+
* pr:7614[], pr:7627[] unleash inner item resolution to users:
16+
+
17+
image::https://user-images.githubusercontent.com/1786438/107394800-8627f300-6afc-11eb-8662-ed07226bc58f.gif[]
18+
19+
* pr:7617[] add generate getter/setter assists:
20+
+
21+
image::https://user-images.githubusercontent.com/3757771/107858728-0b314600-6e36-11eb-9603-8a59f23808e4.gif[]
22+
23+
* pr:7616[] show `Self` pattern and `Self`-prefixed enum variant completions:
24+
+
25+
image::https://user-images.githubusercontent.com/3757771/107413514-1ff99b00-6b11-11eb-88b3-126cd106b514.gif[]
26+
+
27+
image::https://user-images.githubusercontent.com/3757771/107413519-212ac800-6b11-11eb-8282-51115468dccc.gif[]
28+
29+
* pr:7618[] show qualified enum variant pattern completions:
30+
+
31+
image::https://user-images.githubusercontent.com/3757771/107425157-e9c31800-6b1e-11eb-8963-96653115f8e0.gif[]
32+
33+
* pr:7656[] implement constructor usage search for almost all items:
34+
+
35+
image::https://user-images.githubusercontent.com/308347/107944340-9f1a2380-6f96-11eb-8dd9-811d2c7a2d95.gif[]
36+
37+
* pr:7625[] add **Copy Run Command Line** command for Code.
38+
* pr:7644[] implement completion for primitive types.
39+
* pr:7658[] release `x86_64-unknown-linux-musl` binaries.
40+
* pr:7643[] automatically detect `rustc-src` crates.
41+
42+
43+
== Fixes
44+
45+
* pr:7593[] include `for` keyword in completion.
46+
* pr:7602[] check for `dyn` impls in method resolution.
47+
* pr:7591[] fix floating promises in the Code extension.
48+
* pr:7622[] resolve `TupleStructPat` in `SourceAnalyzer::resolve_path`.
49+
* pr:7652[] fix "slow" tests sometimes failing.
50+
* pr:7659[] improve "Generate From impl" assist.
51+
* pr:7665[] fix attribute macro classification.
52+
* pr:7667[] strip type parameter defaults when generating impl generics.
53+
* pr:7663[] tolerate spaces when patching the server binary on NixOS.
54+
55+
== Internal Improvements
56+
57+
* pr:7549[] explain how initial configuration is sent over LSP and document `vim-lsp`.
58+
* pr:7592[] add note about Eclipse IDE support.
59+
* pr:7595[] add `config: &CargoConfig` parameter to `fn load_cargo(…)`.
60+
* pr:7599[] add emacs guide.
61+
* pr:7597[] set remote branch on `xtask promote`.
62+
* pr:7613[], pr:7615[] add initial benchmarking infrastructure.
63+
* pr:7619[], pr:7621[] use `#[track_caller]` in assist tests.
64+
* pr:7648[] fix `legacy_derive_helpers` warning on nightly.
65+
* pr:7653[] document "config" pattern.
66+
* pr:7639[] bump Rust to `1.50`.
67+
* pr:7650[] add `find_impl_block_end` assist helper.
68+
* pr:7358[] refactor reference searching to work with on the `ast`.
69+
* pr:7596[] move `code_lens` to the `ide` crate.
70+
* pr:7655[] include a commit log summary in the changelog.
71+
* pr:7664[] refactor impl generation in assists.
72+
* pr:7668[] finalize rename infra rewrite.
73+
* pr:7678[] simplify `find_crlf`.
74+
* pr:7661[] start LSP 3.17 support.
75+
* pr:7676[] make it clear which client-side commands we use.

0 commit comments

Comments
 (0)