-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add #[allow(clippy::*)] to the top-level items in codegen.rs #1207
Conversation
Hi @T5uku5hi, it looks like you've introduced some syntax errors in the macro-expanded code somewhere: https://travis-ci.com/rustwasm/wasm-bindgen/jobs/172934004#L585 Unfortunately, there isn't a super great way to debug syntax errors within macro-expanded code right now. The two best ways to debug this that I know of is to comment out half of your changes, test to see if the syntax error is there or not. Keep doing this and use a binary search to try and find the code that introduced the syntax errors.
You're still seeing clippy warnings with this patch, and not the syntax errors that CI has? If so, can you share the output? |
@fitzgen
I got the same syntax error as the CI output result. I would like to consult you about next steps. At first, I'll focus on fixing to remove this warning according to your advice.
Is this next step correct? |
If you want to try and pinpoint a single lint warning, https://github.com/dtolnay/cargo-expand might help. But I'm not 100% sure, since debugging proc-macro output is a bit suboptimal currently. I suggest adding one |
@fitzgen thank you so much for your advice. |
@fitzgen |
Are these errors from when you run |
I think the answer is 'yes'. Here is an excerpt from
|
@fitzgen |
crates/backend/src/codegen.rs
Outdated
@@ -899,6 +899,7 @@ impl TryToTokens for ast::ImportFunction { | |||
abi_arguments.push(quote! { #exn_data_ptr: *mut u32 }); | |||
convert_ret = quote! { Ok(#convert_ret) }; | |||
exceptional_ret = quote! { | |||
#[allow(clippy::*)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah I see -- we should only add #[allow(clippy::*)]
to things that are top-level items in the expanded code, not anything that is at the top of a quote!
macro invocation, since it might take multiple quotes to build up a top-level item that we are emitting.
A good rule of thumb is that we should add it on each fn
we define.
Does that make sense?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes!! I understand you said.
I tried to add #[allow(clippy::*)]
to things that are top-level items at first,
but this code occurred another error like this.
error: expected one of `(`, `)`, `,`, or `=`, found `::`
--> crates/backend/src/codegen.rs:15:15
|
15 | #[allow(clippy::*)]
| ^^ expected one of `(`, `)`, `,`, or `=` here
error: unexpected token: `)`
--> crates/backend/src/codegen.rs:15:18
|
15 | #[allow(clippy::*)]
| ^ unexpected token after this
error: aborting due to 2 previous errors
I found that I should use #[allow(clippy::drop_ref)]
instead of #[allow(clippy::*)]
when I read codes written by others 🧐💡
Finally, I fixed it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@T5uku5hi, did you try #![allow(clippy::all)]
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@limira
Oh! I didn't try all
instead of *
.
I tried it just now and I well did it!
I'll add #[allow(clippy::all)]
in all the top-level items.
Thank you for your kindness 😊
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is my bad, sorry!
For some reason I thought the syntax was allow(clippy::*)
and it is actually allow(clippy::all)
as @limira points out. Sorry about that!
@fitzgen |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wonderful! Thanks for sticking with this, and sorry again for the mixup!
This PR it to fix issue #1200.
I added
#[allow(clippy::*)]
to the top-level items incodegen.rs
, but I have a problem 😣Running clippy after fixing, warnings remain print out.
I think I misunderstand how to fix.
Please tell me the correct fixing.