Skip to content

Commit be49044

Browse files
committed
Changelog #98
1 parent 623fda5 commit be49044

File tree

5 files changed

+167
-6
lines changed

5 files changed

+167
-6
lines changed

generated_assists.adoc

Lines changed: 51 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -762,6 +762,32 @@ fn foo<T: Copy + Clone>() { }
762762
```
763763

764764

765+
[discrete]
766+
=== `generate_constant`
767+
**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ide_assists/src/handlers/generate_constant.rs#L12[generate_constant.rs]
768+
769+
Generate a named constant.
770+
771+
.Before
772+
```rust
773+
struct S { i: usize }
774+
impl S { pub fn new(n: usize) {} }
775+
fn main() {
776+
let v = S::new(CAPA┃CITY);
777+
}
778+
```
779+
780+
.After
781+
```rust
782+
struct S { i: usize }
783+
impl S { pub fn new(n: usize) {} }
784+
fn main() {
785+
const CAPACITY: usize = ┃;
786+
let v = S::new(CAPACITY);
787+
}
788+
```
789+
790+
765791
[discrete]
766792
=== `generate_default_from_enum_variant`
767793
**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ide_assists/src/handlers/generate_default_from_enum_variant.rs#L6[generate_default_from_enum_variant.rs]
@@ -1206,7 +1232,7 @@ impl Person {
12061232

12071233
[discrete]
12081234
=== `inline_call`
1209-
**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ide_assists/src/handlers/inline_call.rs#L156[inline_call.rs]
1235+
**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ide_assists/src/handlers/inline_call.rs#L155[inline_call.rs]
12101236

12111237
Inlines a function or method body creating a `let` statement per parameter unless the parameter
12121238
can be inlined. The parameter will be inlined either if it the supplied argument is a simple local
@@ -1999,6 +2025,30 @@ fn main() {
19992025
```
20002026

20012027

2028+
[discrete]
2029+
=== `replace_try_expr_with_match`
2030+
**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ide_assists/src/handlers/replace_try_expr_with_match.rs#L18[replace_try_expr_with_match.rs]
2031+
2032+
Replaces a `try` expression with a `match` expression.
2033+
2034+
.Before
2035+
```rust
2036+
fn handle() {
2037+
let pat = Some(true)┃?;
2038+
}
2039+
```
2040+
2041+
.After
2042+
```rust
2043+
fn handle() {
2044+
let pat = match Some(true) {
2045+
Some(it) => it,
2046+
None => return None,
2047+
};
2048+
}
2049+
```
2050+
2051+
20022052
[discrete]
20032053
=== `sort_items`
20042054
**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ide_assists/src/handlers/sort_items.rs#L12[sort_items.rs]

generated_config.adoc

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,11 @@ Only applies when `#rust-analyzer.completion.addCallParenthesis#` is set.
136136
--
137137
Whether to add parenthesis when completing functions.
138138
--
139+
[[rust-analyzer.completion.snippets]]rust-analyzer.completion.snippets (default: `{}`)::
140+
+
141+
--
142+
Custom completion snippets.
143+
--
139144
[[rust-analyzer.completion.postfix.enable]]rust-analyzer.completion.postfix.enable (default: `true`)::
140145
+
141146
--
@@ -355,8 +360,14 @@ Whether to show `Method References` lens. Only applies when
355360
[[rust-analyzer.lens.references]]rust-analyzer.lens.references (default: `false`)::
356361
+
357362
--
358-
Whether to show `References` lens. Only applies when
359-
`#rust-analyzer.lens.enable#` is set.
363+
Whether to show `References` lens for Struct, Enum, Union and Trait.
364+
Only applies when `#rust-analyzer.lens.enable#` is set.
365+
--
366+
[[rust-analyzer.lens.enumVariantReferences]]rust-analyzer.lens.enumVariantReferences (default: `false`)::
367+
+
368+
--
369+
Whether to show `References` lens for Enum Variants.
370+
Only applies when `#rust-analyzer.lens.enable#` is set.
360371
--
361372
[[rust-analyzer.lens.forceCustomCommands]]rust-analyzer.lens.forceCustomCommands (default: `true`)::
362373
+

generated_diagnostic.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ This diagnostic is shown for macro expansion errors.
3131

3232

3333
=== mismatched-arg-count
34-
**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ide_diagnostics/src/handlers/mismatched_arg_count.rs#L3[mismatched_arg_count.rs]
34+
**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ide_diagnostics/src/handlers/mismatched_arg_count.rs#L10[mismatched_arg_count.rs]
3535

3636
This diagnostic is triggered if a function is invoked with an incorrect amount of arguments.
3737

generated_features.adoc

Lines changed: 55 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@ image::https://user-images.githubusercontent.com/48062697/113020661-b6922200-917
376376

377377

378378
=== Magic Completions
379-
**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ide_completion/src/lib.rs#L33[lib.rs]
379+
**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ide_completion/src/lib.rs#L37[lib.rs]
380380

381381
In addition to usual reference completion, rust-analyzer provides some ✨magic✨
382382
completions as well:
@@ -447,7 +447,7 @@ image::https://user-images.githubusercontent.com/48062697/113065573-04298180-91b
447447

448448

449449
=== Memory Usage
450-
**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ide_db/src/apply_change.rs#L67[apply_change.rs]
450+
**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ide_db/src/apply_change.rs#L41[apply_change.rs]
451451

452452
Clears rust-analyzer's internal database and prints memory usage statistics.
453453

@@ -798,6 +798,59 @@ be parsed as a valid structural search and replace rule.
798798
```
799799

800800

801+
=== User Snippet Completions
802+
**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ide_completion/src/snippet.rs#L5[snippet.rs]
803+
804+
rust-analyzer allows the user to define custom (postfix)-snippets that may depend on items to be accessible for the current scope to be applicable.
805+
806+
A custom snippet can be defined by adding it to the `rust-analyzer.completion.snippets` object respectively.
807+
808+
[source,json]
809+
----
810+
{
811+
"rust-analyzer.completion.snippets": {
812+
"thread spawn": {
813+
"prefix": ["spawn", "tspawn"],
814+
"body": [
815+
"thread::spawn(move || {",
816+
"\t$0",
817+
")};",
818+
],
819+
"description": "Insert a thread::spawn call",
820+
"requires": "std::thread",
821+
"scope": "expr",
822+
}
823+
}
824+
}
825+
----
826+
827+
In the example above:
828+
829+
* `"thread spawn"` is the name of the snippet.
830+
831+
* `prefix` defines one or more trigger words that will trigger the snippets completion.
832+
Using `postfix` will instead create a postfix snippet.
833+
834+
* `body` is one or more lines of content joined via newlines for the final output.
835+
836+
* `description` is an optional description of the snippet, if unset the snippet name will be used.
837+
838+
* `requires` is an optional list of item paths that have to be resolvable in the current crate where the completion is rendered.
839+
On failure of resolution the snippet won't be applicable, otherwise the snippet will insert an import for the items on insertion if
840+
the items aren't yet in scope.
841+
842+
* `scope` is an optional filter for when the snippet should be applicable. Possible values are:
843+
** for Snippet-Scopes: `expr`, `item` (default: `item`)
844+
** for Postfix-Snippet-Scopes: `expr`, `type` (default: `expr`)
845+
846+
The `body` field also has access to placeholders as visible in the example as `$0`.
847+
These placeholders take the form of `$number` or `${number:placeholder_text}` which can be traversed as tabstop in ascending order starting from 1,
848+
with `$0` being a special case that always comes last.
849+
850+
There is also a special placeholder, `${receiver}`, which will be replaced by the receiver expression for postfix snippets, or nothing in case of normal snippets.
851+
It does not act as a tabstop.
852+
853+
801854
=== View Crate Graph
802855
**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ide/src/view_crate_graph.rs#L10[view_crate_graph.rs]
803856

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
= Changelog #98
2+
:sectanchors:
3+
:page-layout: post
4+
5+
Commit: commit:ed4b312fa777ebb39ba1348fe3df574c441a485e[] +
6+
Release: release:2021-10-11[]
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:10476[] (first contribution) add `replace_try_expr_with_match` assist:
16+
+
17+
image::https://user-images.githubusercontent.com/308347/136434480-f0ae5b34-36cb-4bbf-98ca-4b77b58482e1.gif[]
18+
* pr:10447[] (first contribution) implement enum variant code lens:
19+
+
20+
image::https://user-images.githubusercontent.com/308347/136690713-9eb5f108-af80-41c3-86e2-8250b6ef9a40.gif[]
21+
* pr:10458[] implement custom user snippets:
22+
+
23+
image::https://user-images.githubusercontent.com/3757771/136059454-ceccfc2c-2c90-46da-8ad1-bac9c2e83ec1.gif[]
24+
* pr:10459[] add "Generate constant" assist:
25+
+
26+
image::https://user-images.githubusercontent.com/13777628/135885262-c80de86f-5555-4f84-9508-822243f8a876.gif[]
27+
* pr:10474[] support `let...else`.
28+
* pr:10499[] make "mismatched arggument counts" diagnostic range more precise.
29+
30+
== Fixes
31+
32+
* pr:10479[] fix index out of bounds panic in name resolution.
33+
* pr:10456[] avoid cycle when lowering predicates for associated item lookup.
34+
* pr:10482[] fix `inline_call` trying to use an uncached syntax node in `Semantics`.
35+
* pr:10460[] only add `proc_macro` to prelude in proc-macro crates.
36+
* pr:10477[] fix parsing of macro call inside generic args.
37+
* pr:10449[] fix parsing of `Some(1..)`.
38+
* pr:10420[] parse outer attributes on `StructPatternEtCetera`.
39+
* pr:10480[] change snake case fix to match rustc implementation.
40+
41+
== Internal Improvements
42+
43+
* pr:10504[] (first contribution) remove needless clones
44+
* pr:10467[] optimize code lens for references and implementations.
45+
* pr:10494[], pr:10495[], pr:10496[], pr:10497[], pr:10501[], pr:10507[], pr:10508[], pr:10509[], pr:10510[], pr:10512[], pr:10514[] start new macro test suite
46+
* pr:10457[] remove support for pre-1.47 sysroots.
47+
* pr:10440[] fix Clippy warnings and replace some ``if let``s with `match`.

0 commit comments

Comments
 (0)