Skip to content
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

Merged
merged 8 commits into from
Feb 10, 2019
1 change: 1 addition & 0 deletions crates/backend/src/codegen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::*)]
Copy link
Member

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?

Copy link
Contributor Author

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.

Copy link
Contributor

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)]?

Copy link
Contributor Author

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 😊

Copy link
Member

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!

if #exn_data[0] == 1 {
return Err(
<
Expand Down