Skip to content

Commit 73e5a8c

Browse files
authored
Fix clippy lint empty_docs (#3946)
* Do not include docstring if empty Closes #3945 * Move changelog entry to correct section
1 parent ad251c0 commit 73e5a8c

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@
3636
* Fix MSRV compilation.
3737
[#3927](https://github.com/rustwasm/wasm-bindgen/pull/3927)
3838

39+
* Fixed `clippy::empty_docs` lint.
40+
[#3946](https://github.com/rustwasm/wasm-bindgen/pull/3946)
41+
3942
--------------------------------------------------------------------------------
4043

4144
## [0.2.92](https://github.com/rustwasm/wasm-bindgen/compare/0.2.91...0.2.92)

crates/backend/src/codegen.rs

+16-3
Original file line numberDiff line numberDiff line change
@@ -867,10 +867,18 @@ impl ToTokens for ast::ImportType {
867867

868868
let no_deref = self.no_deref;
869869

870+
let doc = if doc_comment.is_empty() {
871+
quote! {}
872+
} else {
873+
quote! {
874+
#[doc = #doc_comment]
875+
}
876+
};
877+
870878
(quote! {
871879
#[automatically_derived]
872880
#(#attrs)*
873-
#[doc = #doc_comment]
881+
#doc
874882
#[repr(transparent)]
875883
#vis struct #rust_name {
876884
obj: #internal_obj
@@ -1319,7 +1327,12 @@ impl TryToTokens for ast::ImportFunction {
13191327
let abi_arguments = &abi_arguments[..];
13201328
let abi_argument_names = &abi_argument_names[..];
13211329

1322-
let doc_comment = &self.doc_comment;
1330+
let doc = if self.doc_comment.is_empty() {
1331+
quote! {}
1332+
} else {
1333+
let doc_comment = &self.doc_comment;
1334+
quote! { #[doc = #doc_comment] }
1335+
};
13231336
let me = if is_method {
13241337
quote! { &self, }
13251338
} else {
@@ -1368,7 +1381,7 @@ impl TryToTokens for ast::ImportFunction {
13681381
#[allow(nonstandard_style)]
13691382
#[allow(clippy::all, clippy::nursery, clippy::pedantic, clippy::restriction)]
13701383
#(#attrs)*
1371-
#[doc = #doc_comment]
1384+
#doc
13721385
#vis #maybe_async #maybe_unsafe fn #rust_name(#me #(#arguments),*) #ret {
13731386
#extern_fn
13741387

0 commit comments

Comments
 (0)