22
33[discrete]
44=== `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]
66
77Specify type for a let binding.
88
@@ -139,6 +139,54 @@ struct Point<'a> {
139139```
140140
141141
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+
142190[discrete]
143191=== `add_turbo_fish`
144192**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() {}
228276
229277[discrete]
230278=== `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]
232280
233281Converts a `bool::then` method call to an equivalent if expression.
234282
@@ -251,9 +299,36 @@ fn main() {
251299```
252300
253301
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+
254329[discrete]
255330=== `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]
257332
258333Converts an if expression into a corresponding `bool::then` call.
259334
@@ -326,7 +401,7 @@ impl From<usize> for Thing {
326401
327402[discrete]
328403=== `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]
330405
331406Converts an Iterator::for_each function into a for loop.
332407
@@ -508,7 +583,7 @@ fn qux(bar: Bar, baz: Baz) {}
508583
509584[discrete]
510585=== `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]
512587
513588Extracts selected statements into new function.
514589
@@ -558,7 +633,7 @@ enum A { One(One) }
558633
559634[discrete]
560635=== `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]
562637
563638Extracts the selected type as a type alias.
564639
@@ -601,36 +676,6 @@ fn main() {
601676```
602677
603678
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-
634679[discrete]
635680=== `fix_visibility`
636681**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 {
9631008
9641009[discrete]
9651010=== `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]
9671012
9681013Adds a stub function with a signature matching the function under the cursor.
9691014
@@ -1160,45 +1205,71 @@ impl Person {
11601205
11611206
11621207[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]
11651210
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.
11681214
11691215.Before
11701216```rust
1171- fn foo() { 4┃2i32 }
1217+ fn foo(name: Option<&str>) {
1218+ let name = name.unwrap┃();
1219+ }
11721220```
11731221
11741222.After
11751223```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+ }
11771230```
11781231
11791232
11801233[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]
11831236
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
11861239or if the parameter is only accessed inside the function body once.
1240+ If all calls can be inlined the function will be removed.
11871241
11881242.Before
11891243```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("여러분");
11921253}
11931254```
11941255
11951256.After
11961257```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+ };
12021273}
12031274```
12041275
@@ -1225,6 +1296,23 @@ fn main() {
12251296```
12261297
12271298
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+
12281316[discrete]
12291317=== `introduce_named_lifetime`
12301318**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) {
13891477
13901478[discrete]
13911479=== `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]
13931481
13941482Moves if expression from match arm body into a guard.
13951483
@@ -1491,6 +1579,26 @@ mod foo;
14911579```
14921580
14931581
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+
14941602[discrete]
14951603=== `pull_assignment_up`
14961604**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 {
17391847```
17401848
17411849
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-
17691850[discrete]
17701851=== `replace_if_let_with_match`
17711852**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) {
17981879```
17991880
18001881
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-
18181882[discrete]
18191883=== `replace_let_with_if_let`
18201884**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