@@ -44,7 +44,7 @@ fn main() {
44
44
45
45
[discrete]
46
46
=== `add_impl_default_members`
47
- **Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ide_assists/src/handlers/add_missing_impl_members.rs#L53 [add_missing_impl_members.rs]
47
+ **Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ide_assists/src/handlers/add_missing_impl_members.rs#L55 [add_missing_impl_members.rs]
48
48
49
49
Adds scaffold for overriding default impl members.
50
50
@@ -81,7 +81,7 @@ impl Trait for () {
81
81
82
82
[discrete]
83
83
=== `add_impl_missing_members`
84
- **Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ide_assists/src/handlers/add_missing_impl_members.rs#L12 [add_missing_impl_members.rs]
84
+ **Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ide_assists/src/handlers/add_missing_impl_members.rs#L14 [add_missing_impl_members.rs]
85
85
86
86
Adds scaffold for required impl members.
87
87
@@ -181,7 +181,7 @@ fn main() {
181
181
.After
182
182
```rust
183
183
fn main() {
184
- if !(x == 4 && !(y < 3.14) ) {}
184
+ if !(x == 4 && y >= 3.14) {}
185
185
}
186
186
```
187
187
@@ -226,9 +226,34 @@ pub(crate) fn frobnicate() {}
226
226
```
227
227
228
228
229
+ [discrete]
230
+ === `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]
232
+
233
+ Converts a `bool::then` method call to an equivalent if expression.
234
+
235
+ .Before
236
+ ```rust
237
+ fn main() {
238
+ (0 == 0).then┃(|| val)
239
+ }
240
+ ```
241
+
242
+ .After
243
+ ```rust
244
+ fn main() {
245
+ if 0 == 0 {
246
+ Some(val)
247
+ } else {
248
+ None
249
+ }
250
+ }
251
+ ```
252
+
253
+
229
254
[discrete]
230
255
=== `convert_if_to_bool_then`
231
- **Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ide_assists/src/handlers/convert_bool_then.rs#L16 [convert_bool_then.rs]
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]
232
257
233
258
Converts an if expression into a corresponding `bool::then` call.
234
259
@@ -328,7 +353,7 @@ fn main() {
328
353
329
354
[discrete]
330
355
=== `convert_to_guarded_return`
331
- **Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ide_assists/src/handlers/early_return .rs#L21[early_return .rs]
356
+ **Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ide_assists/src/handlers/convert_to_guarded_return .rs#L20[convert_to_guarded_return .rs]
332
357
333
358
Replace a large conditional with a guarded return.
334
359
@@ -1127,7 +1152,7 @@ fn foo(name: Option<&str>) {
1127
1152
1128
1153
[discrete]
1129
1154
=== `inline_local_variable`
1130
- **Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ide_assists/src/handlers/inline_local_variable.rs#L17 [inline_local_variable.rs]
1155
+ **Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ide_assists/src/handlers/inline_local_variable.rs#L19 [inline_local_variable.rs]
1131
1156
1132
1157
Inlines a local variable.
1133
1158
@@ -1290,7 +1315,7 @@ fn handle(action: Action) {
1290
1315
1291
1316
[discrete]
1292
1317
=== `move_arm_cond_to_match_guard`
1293
- **Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ide_assists/src/handlers/move_guard.rs#L68 [move_guard.rs]
1318
+ **Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ide_assists/src/handlers/move_guard.rs#L72 [move_guard.rs]
1294
1319
1295
1320
Moves if expression from match arm body into a guard.
1296
1321
@@ -1617,7 +1642,7 @@ fn main() {
1617
1642
1618
1643
[discrete]
1619
1644
=== `replace_derive_with_manual_impl`
1620
- **Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ide_assists/src/handlers/replace_derive_with_manual_impl.rs#L21 [replace_derive_with_manual_impl.rs]
1645
+ **Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ide_assists/src/handlers/replace_derive_with_manual_impl.rs#L19 [replace_derive_with_manual_impl.rs]
1621
1646
1622
1647
Converts a `derive` impl into a manual one.
1623
1648
@@ -1816,6 +1841,98 @@ fn main() {
1816
1841
```
1817
1842
1818
1843
1844
+ [discrete]
1845
+ === `sort_items`
1846
+ **Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ide_assists/src/handlers/sort_items.rs#L12[sort_items.rs]
1847
+
1848
+ Sorts item members alphabetically: fields, enum variants and methods.
1849
+
1850
+ .Before
1851
+ ```rust
1852
+ struct ┃Foo┃ { second: u32, first: String }
1853
+ ```
1854
+
1855
+ .After
1856
+ ```rust
1857
+ struct Foo { first: String, second: u32 }
1858
+ ```
1859
+
1860
+ ---
1861
+
1862
+ .Before
1863
+ ```rust
1864
+ trait ┃Bar┃ {
1865
+ fn second(&self) -> u32;
1866
+ fn first(&self) -> String;
1867
+ }
1868
+ ```
1869
+
1870
+ .After
1871
+ ```rust
1872
+ trait Bar {
1873
+ fn first(&self) -> String;
1874
+ fn second(&self) -> u32;
1875
+ }
1876
+ ```
1877
+
1878
+ ---
1879
+
1880
+ .Before
1881
+ ```rust
1882
+ struct Baz;
1883
+ impl ┃Baz┃ {
1884
+ fn second(&self) -> u32;
1885
+ fn first(&self) -> String;
1886
+ }
1887
+ ```
1888
+
1889
+ .After
1890
+ ```rust
1891
+ struct Baz;
1892
+ impl Baz {
1893
+ fn first(&self) -> String;
1894
+ fn second(&self) -> u32;
1895
+ }
1896
+ ```
1897
+
1898
+ ---
1899
+ There is a difference between sorting enum variants:
1900
+
1901
+ .Before
1902
+ ```rust
1903
+ enum ┃Animal┃ {
1904
+ Dog(String, f64),
1905
+ Cat { weight: f64, name: String },
1906
+ }
1907
+ ```
1908
+
1909
+ .After
1910
+ ```rust
1911
+ enum Animal {
1912
+ Cat { weight: f64, name: String },
1913
+ Dog(String, f64),
1914
+ }
1915
+ ```
1916
+
1917
+ and sorting a single enum struct variant:
1918
+
1919
+ .Before
1920
+ ```rust
1921
+ enum Animal {
1922
+ Dog(String, f64),
1923
+ Cat ┃{ weight: f64, name: String }┃,
1924
+ }
1925
+ ```
1926
+
1927
+ .After
1928
+ ```rust
1929
+ enum Animal {
1930
+ Dog(String, f64),
1931
+ Cat { name: String, weight: f64 },
1932
+ }
1933
+ ```
1934
+
1935
+
1819
1936
[discrete]
1820
1937
=== `split_import`
1821
1938
**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ide_assists/src/handlers/split_import.rs#L5[split_import.rs]
0 commit comments