Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit e315124

Browse files
committed
Remove "Sort methods by trait definition" assist
It was replaced by the "Sort items by trait definition" assist.
1 parent 2b20a05 commit e315124

File tree

4 files changed

+24
-267
lines changed

4 files changed

+24
-267
lines changed

crates/ide-assists/src/handlers/reorder_impl.rs

Lines changed: 0 additions & 217 deletions
This file was deleted.

crates/ide-assists/src/handlers/reorder_impl_items.rs

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,6 @@ pub(crate) fn reorder_impl_items(acc: &mut Assists, ctx: &AssistContext) -> Opti
4747
let items = impl_ast.assoc_item_list()?;
4848
let assoc_items = items.assoc_items().collect::<Vec<_>>();
4949

50-
// If all items are either function or macro calls, then reorder_impl assist can be used
51-
if assoc_items.iter().all(|i| matches!(i, ast::AssocItem::Fn(_) | ast::AssocItem::MacroCall(_)))
52-
{
53-
cov_mark::hit!(not_applicable_if_all_functions);
54-
return None;
55-
}
56-
5750
let path = impl_ast
5851
.trait_()
5952
.and_then(|t| match t {
@@ -152,23 +145,41 @@ $0impl Bar for Foo {
152145
}
153146

154147
#[test]
155-
fn not_applicable_if_all_functions() {
156-
cov_mark::check!(not_applicable_if_all_functions);
157-
check_assist_not_applicable(
148+
fn reorder_impl_trait_functions() {
149+
check_assist(
158150
reorder_impl_items,
159151
r#"
160152
trait Bar {
161153
fn a() {}
162-
fn z() {}
154+
fn c() {}
163155
fn b() {}
156+
fn d() {}
164157
}
158+
165159
struct Foo;
166160
$0impl Bar for Foo {
161+
fn d() {}
162+
fn b() {}
163+
fn c() {}
167164
fn a() {}
168-
fn z() {}
165+
}
166+
"#,
167+
r#"
168+
trait Bar {
169+
fn a() {}
170+
fn c() {}
169171
fn b() {}
172+
fn d() {}
170173
}
171-
"#,
174+
175+
struct Foo;
176+
impl Bar for Foo {
177+
fn a() {}
178+
fn c() {}
179+
fn b() {}
180+
fn d() {}
181+
}
182+
"#,
172183
)
173184
}
174185

crates/ide-assists/src/lib.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,6 @@ mod handlers {
169169
mod remove_mut;
170170
mod remove_unused_param;
171171
mod reorder_fields;
172-
mod reorder_impl;
173172
mod reorder_impl_items;
174173
mod replace_try_expr_with_match;
175174
mod replace_derive_with_manual_impl;
@@ -257,7 +256,6 @@ mod handlers {
257256
remove_mut::remove_mut,
258257
remove_unused_param::remove_unused_param,
259258
reorder_fields::reorder_fields,
260-
reorder_impl::reorder_impl,
261259
reorder_impl_items::reorder_impl_items,
262260
replace_try_expr_with_match::replace_try_expr_with_match,
263261
replace_derive_with_manual_impl::replace_derive_with_manual_impl,

crates/ide-assists/src/tests/generated.rs

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1736,41 +1736,6 @@ const test: Foo = Foo {foo: 1, bar: 0}
17361736
)
17371737
}
17381738

1739-
#[test]
1740-
fn doctest_reorder_impl() {
1741-
check_doc_test(
1742-
"reorder_impl",
1743-
r#####"
1744-
trait Foo {
1745-
fn a() {}
1746-
fn b() {}
1747-
fn c() {}
1748-
}
1749-
1750-
struct Bar;
1751-
$0impl Foo for Bar {
1752-
fn b() {}
1753-
fn c() {}
1754-
fn a() {}
1755-
}
1756-
"#####,
1757-
r#####"
1758-
trait Foo {
1759-
fn a() {}
1760-
fn b() {}
1761-
fn c() {}
1762-
}
1763-
1764-
struct Bar;
1765-
impl Foo for Bar {
1766-
fn a() {}
1767-
fn b() {}
1768-
fn c() {}
1769-
}
1770-
"#####,
1771-
)
1772-
}
1773-
17741739
#[test]
17751740
fn doctest_reorder_impl_items() {
17761741
check_doc_test(

0 commit comments

Comments
 (0)