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

Clippy reports errors from macro even if they are marked with allow(clippy::all) #11132

Closed
DrSloth opened this issue Jul 9, 2023 · 5 comments
Labels
C-bug Category: Clippy is not doing the correct thing

Comments

@DrSloth
Copy link

DrSloth commented Jul 9, 2023

Summary

This error occurred while writing code with sqlx in the macro expansion the code is marked with #[allow(clippy::all)] but the lints arithmetic_side_effects and missing_panic_docs still fire.

The second one might still make sense to keep because it CAN panic but in the sqlx sense that should never happen.

Reproducer

I tried this code:
Any sqlx query with bind parameters should work

sqlx::query_as!(Foo, "SELECT boo, baz FROM Foos WHERE boo > $1 AND baz < $2", 10, 20)

I expected to see this happen:
No errors reported

Instead, this happened:
Clippy reports arithmetic_side_effects because it increments the bind parameter count. Also it reports missing_panic_docs because sqlx panics if the database schema is wrong.

Version

rustc 1.70.0 (90c541806 2023-05-31)
binary: rustc
commit-hash: 90c541806f23a127002de5b4038be731ba1458ca
commit-date: 2023-05-31
host: x86_64-unknown-linux-gnu
release: 1.70.0
LLVM version: 16.0.2

Additional Labels

No response

@DrSloth DrSloth added the C-bug Category: Clippy is not doing the correct thing label Jul 9, 2023
@Centri3
Copy link
Member

Centri3 commented Jul 10, 2023

clippy::all only includes all that are warn/deny, so those lints aren't included. You may want to try to allow those specific lints instead.

@DrSloth
Copy link
Author

DrSloth commented Jul 10, 2023

Thanks, how can i allow this if it comes from a macro invocation the attribute on the macro invocation is ignored.

@Centri3
Copy link
Member

Centri3 commented Jul 11, 2023

You could probably do something like

#[allow(clippy::arithmetic_side_effects, clippy::missing_panic_docs)]
{ sqlx::query_as!(Foo, "SELECT boo, baz FROM Foos WHERE boo > $1 AND baz < $2", 10, 20) }

But the lints should be updated to ignore proc macros instead.

@c410-f3r
Copy link
Contributor

#10203, that is included in version 1.71, should fix this problem.

@Alexendoo
Copy link
Member

closing per #11132 (comment), if this is still an issue though please re-open

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: Clippy is not doing the correct thing
Projects
None yet
Development

No branches or pull requests

4 participants