Skip to content

Commit

Permalink
Auto merge of #15854 - alibektas:15782/relax_hidden_attr, r=lnicola
Browse files Browse the repository at this point in the history
fix: Ignore doc(hidden) attr if no body is present

fixes #15782
  • Loading branch information
bors committed Nov 10, 2023
2 parents 5afaf68 + b0101da commit 7cca4e5
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 2 deletions.
31 changes: 31 additions & 0 deletions crates/ide-assists/src/handlers/add_missing_impl_members.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2245,6 +2245,37 @@ impl b::LocalTrait for B {
fn no_skip_default_2() -> Option<()> {
todo!()
}
}
"#,
)
}

#[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!()}
}
}
"#,
)
Expand Down
14 changes: 12 additions & 2 deletions crates/ide-assists/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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| {
Expand Down

0 comments on commit 7cca4e5

Please sign in to comment.