Skip to content

Commit

Permalink
Fix clippy lint empty_docs (#3946)
Browse files Browse the repository at this point in the history
* Do not include docstring if empty

Closes #3945

* Move changelog entry to correct section
  • Loading branch information
kflansburg authored May 8, 2024
1 parent ad251c0 commit 73e5a8c
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@
* Fix MSRV compilation.
[#3927](https://github.com/rustwasm/wasm-bindgen/pull/3927)

* Fixed `clippy::empty_docs` lint.
[#3946](https://github.com/rustwasm/wasm-bindgen/pull/3946)

--------------------------------------------------------------------------------

## [0.2.92](https://github.com/rustwasm/wasm-bindgen/compare/0.2.91...0.2.92)
Expand Down
19 changes: 16 additions & 3 deletions crates/backend/src/codegen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -867,10 +867,18 @@ impl ToTokens for ast::ImportType {

let no_deref = self.no_deref;

let doc = if doc_comment.is_empty() {
quote! {}
} else {
quote! {
#[doc = #doc_comment]
}
};

(quote! {
#[automatically_derived]
#(#attrs)*
#[doc = #doc_comment]
#doc
#[repr(transparent)]
#vis struct #rust_name {
obj: #internal_obj
Expand Down Expand Up @@ -1319,7 +1327,12 @@ impl TryToTokens for ast::ImportFunction {
let abi_arguments = &abi_arguments[..];
let abi_argument_names = &abi_argument_names[..];

let doc_comment = &self.doc_comment;
let doc = if self.doc_comment.is_empty() {
quote! {}
} else {
let doc_comment = &self.doc_comment;
quote! { #[doc = #doc_comment] }
};
let me = if is_method {
quote! { &self, }
} else {
Expand Down Expand Up @@ -1368,7 +1381,7 @@ impl TryToTokens for ast::ImportFunction {
#[allow(nonstandard_style)]
#[allow(clippy::all, clippy::nursery, clippy::pedantic, clippy::restriction)]
#(#attrs)*
#[doc = #doc_comment]
#doc
#vis #maybe_async #maybe_unsafe fn #rust_name(#me #(#arguments),*) #ret {
#extern_fn

Expand Down

0 comments on commit 73e5a8c

Please sign in to comment.