Auto merge of #15854 - alibektas:15782/relax_hidden_attr, r=lnicola

fix: Ignore doc(hidden) attr if no body is present

fixes #15782
This commit is contained in:
bors 2023-11-10 13:30:52 +00:00
commit 7cca4e5816
2 changed files with 43 additions and 2 deletions

View file

@ -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!()}
}
}
"#,
)

View file

@ -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| {