diff options
| author | Ali Bektas <bektasali@protonmail.com> | 2023-11-09 02:12:53 +0100 |
|---|---|---|
| committer | Ali Bektas <bektasali@protonmail.com> | 2023-11-09 02:12:53 +0100 |
| commit | b0101da1166b1a813b3853b3043dfe85f1081fdb (patch) | |
| tree | ed25e8a35c2c5fdb42dc612bf7dd90ace05aedae | |
| parent | c1c9e10f72ffd2e829d20ff1439ff49c2e121731 (diff) | |
| download | rust-b0101da1166b1a813b3853b3043dfe85f1081fdb.tar.gz rust-b0101da1166b1a813b3853b3043dfe85f1081fdb.zip | |
Ignore doc(hidden) attr if no body is present
| -rw-r--r-- | crates/ide-assists/src/handlers/add_missing_impl_members.rs | 31 | ||||
| -rw-r--r-- | crates/ide-assists/src/utils.rs | 14 |
2 files changed, 43 insertions, 2 deletions
diff --git a/crates/ide-assists/src/handlers/add_missing_impl_members.rs b/crates/ide-assists/src/handlers/add_missing_impl_members.rs index c0e5429a22c..410c623109e 100644 --- a/crates/ide-assists/src/handlers/add_missing_impl_members.rs +++ b/crates/ide-assists/src/handlers/add_missing_impl_members.rs @@ -2249,4 +2249,35 @@ impl b::LocalTrait for B { "#, ) } + + #[test] + fn doc_hidden_nondefault_member() { + check_assist( + add_missing_impl_members, + r#" +//- /lib.rs crate:b new_source_root:local +trait LocalTrait { + #[doc(hidden)] + fn no_skip_non_default() -> Option<()>; + + #[doc(hidden)] + fn skip_default() -> Option<()> { + todo!() + } +} + +//- /main.rs crate:a deps:b +struct B; +impl b::Loc$0alTrait for B {} + "#, + r#" +struct B; +impl b::LocalTrait for B { + fn no_skip_non_default() -> Option<()> { + ${0:todo!()} + } +} + "#, + ) + } } diff --git a/crates/ide-assists/src/utils.rs b/crates/ide-assists/src/utils.rs index a262570d94e..f51e99a914e 100644 --- a/crates/ide-assists/src/utils.rs +++ b/crates/ide-assists/src/utils.rs @@ -106,8 +106,18 @@ pub fn filter_assoc_items( .iter() .copied() .filter(|assoc_item| { - !(ignore_items == IgnoreAssocItems::DocHiddenAttrPresent - && assoc_item.attrs(sema.db).has_doc_hidden()) + if ignore_items == IgnoreAssocItems::DocHiddenAttrPresent + && assoc_item.attrs(sema.db).has_doc_hidden() + { + if let hir::AssocItem::Function(f) = assoc_item { + if !f.has_body(sema.db) { + return true; + } + } + return false; + } + + return true; }) // Note: This throws away items with no source. .filter_map(|assoc_item| { |
