2
2
3
3
[discrete]
4
4
=== `add_explicit_type`
5
- **Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ide_assists/src/handlers/add_explicit_type.rs#L6 [add_explicit_type.rs]
5
+ **Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ide_assists/src/handlers/add_explicit_type.rs#L7 [add_explicit_type.rs]
6
6
7
7
Specify type for a let binding.
8
8
@@ -139,6 +139,54 @@ struct Point<'a> {
139
139
```
140
140
141
141
142
+ [discrete]
143
+ === `add_missing_match_arms`
144
+ **Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ide_assists/src/handlers/add_missing_match_arms.rs#L15[add_missing_match_arms.rs]
145
+
146
+ Adds missing clauses to a `match` expression.
147
+
148
+ .Before
149
+ ```rust
150
+ enum Action { Move { distance: u32 }, Stop }
151
+
152
+ fn handle(action: Action) {
153
+ match action {
154
+ ┃
155
+ }
156
+ }
157
+ ```
158
+
159
+ .After
160
+ ```rust
161
+ enum Action { Move { distance: u32 }, Stop }
162
+
163
+ fn handle(action: Action) {
164
+ match action {
165
+ ┃Action::Move { distance } => todo!(),
166
+ Action::Stop => todo!(),
167
+ }
168
+ }
169
+ ```
170
+
171
+
172
+ [discrete]
173
+ === `add_return_type`
174
+ **Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ide_assists/src/handlers/add_return_type.rs#L6[add_return_type.rs]
175
+
176
+ Adds the return type to a function or closure inferred from its tail expression if it doesn't have a return
177
+ type specified. This assists is useable in a functions or closures tail expression or return type position.
178
+
179
+ .Before
180
+ ```rust
181
+ fn foo() { 4┃2i32 }
182
+ ```
183
+
184
+ .After
185
+ ```rust
186
+ fn foo() -> i32 { 42i32 }
187
+ ```
188
+
189
+
142
190
[discrete]
143
191
=== `add_turbo_fish`
144
192
**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ide_assists/src/handlers/add_turbo_fish.rs#L9[add_turbo_fish.rs]
@@ -228,7 +276,7 @@ pub(crate) fn frobnicate() {}
228
276
229
277
[discrete]
230
278
=== `convert_bool_then_to_if`
231
- **Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ide_assists/src/handlers/convert_bool_then.rs#L108 [convert_bool_then.rs]
279
+ **Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ide_assists/src/handlers/convert_bool_then.rs#L112 [convert_bool_then.rs]
232
280
233
281
Converts a `bool::then` method call to an equivalent if expression.
234
282
@@ -251,9 +299,36 @@ fn main() {
251
299
```
252
300
253
301
302
+ [discrete]
303
+ === `convert_for_loop_with_for_each`
304
+ **Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ide_assists/src/handlers/convert_iter_for_each_to_for.rs#L73[convert_iter_for_each_to_for.rs]
305
+
306
+ Converts a for loop into a for_each loop on the Iterator.
307
+
308
+ .Before
309
+ ```rust
310
+ fn main() {
311
+ let x = vec![1, 2, 3];
312
+ for┃ v in x {
313
+ let y = v * 2;
314
+ }
315
+ }
316
+ ```
317
+
318
+ .After
319
+ ```rust
320
+ fn main() {
321
+ let x = vec![1, 2, 3];
322
+ x.into_iter().for_each(|v| {
323
+ let y = v * 2;
324
+ });
325
+ }
326
+ ```
327
+
328
+
254
329
[discrete]
255
330
=== `convert_if_to_bool_then`
256
- **Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ide_assists/src/handlers/convert_bool_then.rs#L17 [convert_bool_then.rs]
331
+ **Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ide_assists/src/handlers/convert_bool_then.rs#L21 [convert_bool_then.rs]
257
332
258
333
Converts an if expression into a corresponding `bool::then` call.
259
334
@@ -326,7 +401,7 @@ impl From<usize> for Thing {
326
401
327
402
[discrete]
328
403
=== `convert_iter_for_each_to_for`
329
- **Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ide_assists/src/handlers/convert_iter_for_each_to_for.rs#L9 [convert_iter_for_each_to_for.rs]
404
+ **Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ide_assists/src/handlers/convert_iter_for_each_to_for.rs#L11 [convert_iter_for_each_to_for.rs]
330
405
331
406
Converts an Iterator::for_each function into a for loop.
332
407
@@ -508,7 +583,7 @@ fn qux(bar: Bar, baz: Baz) {}
508
583
509
584
[discrete]
510
585
=== `extract_function`
511
- **Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ide_assists/src/handlers/extract_function.rs#L32 [extract_function.rs]
586
+ **Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ide_assists/src/handlers/extract_function.rs#L33 [extract_function.rs]
512
587
513
588
Extracts selected statements into new function.
514
589
@@ -558,7 +633,7 @@ enum A { One(One) }
558
633
559
634
[discrete]
560
635
=== `extract_type_alias`
561
- **Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ide_assists/src/handlers/extract_type_alias.rs#L10 [extract_type_alias.rs]
636
+ **Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ide_assists/src/handlers/extract_type_alias.rs#L11 [extract_type_alias.rs]
562
637
563
638
Extracts the selected type as a type alias.
564
639
@@ -601,36 +676,6 @@ fn main() {
601
676
```
602
677
603
678
604
- [discrete]
605
- === `fill_match_arms`
606
- **Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ide_assists/src/handlers/fill_match_arms.rs#L15[fill_match_arms.rs]
607
-
608
- Adds missing clauses to a `match` expression.
609
-
610
- .Before
611
- ```rust
612
- enum Action { Move { distance: u32 }, Stop }
613
-
614
- fn handle(action: Action) {
615
- match action {
616
- ┃
617
- }
618
- }
619
- ```
620
-
621
- .After
622
- ```rust
623
- enum Action { Move { distance: u32 }, Stop }
624
-
625
- fn handle(action: Action) {
626
- match action {
627
- ┃Action::Move { distance } => todo!(),
628
- Action::Stop => todo!(),
629
- }
630
- }
631
- ```
632
-
633
-
634
679
[discrete]
635
680
=== `fix_visibility`
636
681
**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ide_assists/src/handlers/fix_visibility.rs#L12[fix_visibility.rs]
@@ -963,7 +1008,7 @@ impl From<u32> for A {
963
1008
964
1009
[discrete]
965
1010
=== `generate_function`
966
- **Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ide_assists/src/handlers/generate_function.rs#L20 [generate_function.rs]
1011
+ **Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ide_assists/src/handlers/generate_function.rs#L25 [generate_function.rs]
967
1012
968
1013
Adds a stub function with a signature matching the function under the cursor.
969
1014
@@ -1160,45 +1205,71 @@ impl Person {
1160
1205
1161
1206
1162
1207
[discrete]
1163
- === `infer_function_return_type `
1164
- **Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ide_assists/src/handlers/infer_function_return_type .rs#L6[infer_function_return_type .rs]
1208
+ === `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]
1165
1210
1166
- Adds the return type to a function or closure inferred from its tail expression if it doesn't have a return
1167
- type specified. This assists is useable in a functions or closures tail expression or return type position.
1211
+ Inlines a function or method body creating a `let` statement per parameter unless the parameter
1212
+ can be inlined. The parameter will be inlined either if it the supplied argument is a simple local
1213
+ or if the parameter is only accessed inside the function body once.
1168
1214
1169
1215
.Before
1170
1216
```rust
1171
- fn foo() { 4┃2i32 }
1217
+ fn foo(name: Option<&str>) {
1218
+ let name = name.unwrap┃();
1219
+ }
1172
1220
```
1173
1221
1174
1222
.After
1175
1223
```rust
1176
- fn foo() -> i32 { 42i32 }
1224
+ fn foo(name: Option<&str>) {
1225
+ let name = match name {
1226
+ Some(val) => val,
1227
+ None => panic!("called `Option::unwrap()` on a `None` value"),
1228
+ };
1229
+ }
1177
1230
```
1178
1231
1179
1232
1180
1233
[discrete]
1181
- === `inline_call `
1182
- **Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ide_assists/src/handlers/inline_call.rs#L15 [inline_call.rs]
1234
+ === `inline_into_callers `
1235
+ **Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ide_assists/src/handlers/inline_call.rs#L23 [inline_call.rs]
1183
1236
1184
- Inlines a function or method body creating a `let` statement per parameter unless the parameter
1185
- can be inlined. The parameter will be inlined either if it the supplied argument is a simple local
1237
+ Inline a function or method body into all of its callers where possible, creating a `let` statement per parameter
1238
+ unless the parameter can be inlined. The parameter will be inlined either if it the supplied argument is a simple local
1186
1239
or if the parameter is only accessed inside the function body once.
1240
+ If all calls can be inlined the function will be removed.
1187
1241
1188
1242
.Before
1189
1243
```rust
1190
- fn foo(name: Option<&str>) {
1191
- let name = name.unwrap┃();
1244
+ fn print(_: &str) {}
1245
+ fn foo┃(word: &str) {
1246
+ if !word.is_empty() {
1247
+ print(word);
1248
+ }
1249
+ }
1250
+ fn bar() {
1251
+ foo("안녕하세요");
1252
+ foo("여러분");
1192
1253
}
1193
1254
```
1194
1255
1195
1256
.After
1196
1257
```rust
1197
- fn foo(name: Option<&str>) {
1198
- let name = match name {
1199
- Some(val) => val,
1200
- None => panic!("called `Option::unwrap()` on a `None` value"),
1201
- };
1258
+ fn print(_: &str) {}
1259
+
1260
+ fn bar() {
1261
+ {
1262
+ let word = "안녕하세요";
1263
+ if !word.is_empty() {
1264
+ print(word);
1265
+ }
1266
+ };
1267
+ {
1268
+ let word = "여러분";
1269
+ if !word.is_empty() {
1270
+ print(word);
1271
+ }
1272
+ };
1202
1273
}
1203
1274
```
1204
1275
@@ -1225,6 +1296,23 @@ fn main() {
1225
1296
```
1226
1297
1227
1298
1299
+ [discrete]
1300
+ === `introduce_named_generic`
1301
+ **Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ide_assists/src/handlers/introduce_named_generic.rs#L8[introduce_named_generic.rs]
1302
+
1303
+ Replaces `impl Trait` function argument with the named generic.
1304
+
1305
+ .Before
1306
+ ```rust
1307
+ fn foo(bar: ┃impl Bar) {}
1308
+ ```
1309
+
1310
+ .After
1311
+ ```rust
1312
+ fn foo<B: Bar>(bar: B) {}
1313
+ ```
1314
+
1315
+
1228
1316
[discrete]
1229
1317
=== `introduce_named_lifetime`
1230
1318
**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ide_assists/src/handlers/introduce_named_lifetime.rs#L13[introduce_named_lifetime.rs]
@@ -1389,7 +1477,7 @@ fn handle(action: Action) {
1389
1477
1390
1478
[discrete]
1391
1479
=== `move_arm_cond_to_match_guard`
1392
- **Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ide_assists/src/handlers/move_guard.rs#L72 [move_guard.rs]
1480
+ **Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ide_assists/src/handlers/move_guard.rs#L76 [move_guard.rs]
1393
1481
1394
1482
Moves if expression from match arm body into a guard.
1395
1483
@@ -1491,6 +1579,26 @@ mod foo;
1491
1579
```
1492
1580
1493
1581
1582
+ [discrete]
1583
+ === `move_to_mod_rs`
1584
+ **Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ide_assists/src/handlers/move_to_mod_rs.rs#L38[move_to_mod_rs.rs]
1585
+
1586
+ Moves xxx.rs to xxx/mod.rs.
1587
+
1588
+ .Before
1589
+ ```rust
1590
+ //- /main.rs
1591
+ mod a;
1592
+ //- /a.rs
1593
+ ┃fn t() {}┃
1594
+ ```
1595
+
1596
+ .After
1597
+ ```rust
1598
+ fn t() {}
1599
+ ```
1600
+
1601
+
1494
1602
[discrete]
1495
1603
=== `pull_assignment_up`
1496
1604
**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ide_assists/src/handlers/pull_assignment_up.rs#L11[pull_assignment_up.rs]
@@ -1739,33 +1847,6 @@ impl Debug for S {
1739
1847
```
1740
1848
1741
1849
1742
- [discrete]
1743
- === `replace_for_loop_with_for_each`
1744
- **Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ide_assists/src/handlers/replace_for_loop_with_for_each.rs#L9[replace_for_loop_with_for_each.rs]
1745
-
1746
- Converts a for loop into a for_each loop on the Iterator.
1747
-
1748
- .Before
1749
- ```rust
1750
- fn main() {
1751
- let x = vec![1, 2, 3];
1752
- for┃ v in x {
1753
- let y = v * 2;
1754
- }
1755
- }
1756
- ```
1757
-
1758
- .After
1759
- ```rust
1760
- fn main() {
1761
- let x = vec![1, 2, 3];
1762
- x.into_iter().for_each(|v| {
1763
- let y = v * 2;
1764
- });
1765
- }
1766
- ```
1767
-
1768
-
1769
1850
[discrete]
1770
1851
=== `replace_if_let_with_match`
1771
1852
**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ide_assists/src/handlers/replace_if_let_with_match.rs#L19[replace_if_let_with_match.rs]
@@ -1798,23 +1879,6 @@ fn handle(action: Action) {
1798
1879
```
1799
1880
1800
1881
1801
- [discrete]
1802
- === `replace_impl_trait_with_generic`
1803
- **Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ide_assists/src/handlers/replace_impl_trait_with_generic.rs#L8[replace_impl_trait_with_generic.rs]
1804
-
1805
- Replaces `impl Trait` function argument with the named generic.
1806
-
1807
- .Before
1808
- ```rust
1809
- fn foo(bar: ┃impl Bar) {}
1810
- ```
1811
-
1812
- .After
1813
- ```rust
1814
- fn foo<B: Bar>(bar: B) {}
1815
- ```
1816
-
1817
-
1818
1882
[discrete]
1819
1883
=== `replace_let_with_if_let`
1820
1884
**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ide_assists/src/handlers/replace_let_with_if_let.rs#L15[replace_let_with_if_let.rs]
0 commit comments