-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Ignore generated code #702
Comments
You can just stick You may also need to |
|
… errors for Code generated by protobuf contains #![allow(clippy)] directives, which are incompatible with setting any clippy lints as forbidden. Using deny instead gives errors in other context, but still allows the generated code to suppress output we're not interested in. See https://github.com/Manishearth/rust-clippy/issues/702 for more on why the generated code needs to allow clippy lints to be ignored. Signed-off-by: Jon Bauman <5906042+baumanj@users.noreply.github.com>
… errors for Code generated by protobuf contains #![allow(clippy)] directives, which are incompatible with setting any clippy lints as forbidden. Using deny instead gives errors in other context, but still allows the generated code to suppress output we're not interested in. See https://github.com/Manishearth/rust-clippy/issues/702 for more on why the generated code needs to allow clippy lints to be ignored. Signed-off-by: Jon Bauman <5906042+baumanj@users.noreply.github.com>
… errors for Code generated by protobuf contains #![allow(clippy)] directives, which are incompatible with setting any clippy lints as forbidden. Using deny instead gives errors in other context, but still allows the generated code to suppress output we're not interested in. See https://github.com/Manishearth/rust-clippy/issues/702 for more on why the generated code needs to allow clippy lints to be ignored. Signed-off-by: Jon Bauman <5906042+baumanj@users.noreply.github.com>
… errors for Code generated by protobuf contains #![allow(clippy)] directives, which are incompatible with setting any clippy lints as forbidden. Using deny instead gives errors in other context, but still allows the generated code to suppress output we're not interested in. See https://github.com/Manishearth/rust-clippy/issues/702 for more on why the generated code needs to allow clippy lints to be ignored. Signed-off-by: Jon Bauman <5906042+baumanj@users.noreply.github.com>
I would expect to be able to do the following in scope:
or possibly
In my case it is reporting a false positive that I would like to suppress, but I would like to use it to check other parts of the source code. Also: When will clippy be available in stable? |
You can simply attach |
This all works until I add '-- -D warnings' to the clippy invocation and it upgrades a warning from the compiler and the build. Here's the example:
I have:
Before the include, does anyone know if it's possible to turn off everything for this file, so I can keep -D warnings? |
I get the following compiler info with this line from the generated code:
Changing to |
Could anyone please explain why we should ever care about code that originates from macro expansions? Such code tends to be redundant, complex, and unclear - but soulless machine does not and should not care about it. |
Yes, that's what |
@Manishearth I'm not talking about auto-generated files, it's about macro expansions. Any chance we may have it? |
We ignore macro expansions for most lints. File a bug for a specific lint and code example, we can fix it. This is the wrong place for this complaint. |
I'm currently working for better error messages for my proc macro attributes. My approach is to use spans of user code when expanding the proc macro attribute so that the rustc error messages would point to the bad bits in the user code instead of the This resulted in clippy not ignoring those bits anymore. Google brought me here and (Sorry for the noise, figured I'd clarify this here given this issue was rather high up in Google results.) |
@Rantanen yes, this is exactly what we did in the end |
Uhm, is this supposed to work?
Using stable Clippy as of today. |
Ah right, I see - you have to put |
@Timmmm no, you need to do |
I'm trying to disable clippy on auto-generated protobuf (tokio-rs/prost) but not sure what to do, I've tried the above suggestions but it still gives warnings on auto-generated files. I've tried it throws warns on target |
There is no builder.rs file in that repo. Are you sure you have the |
@llogiq |
You need to either
We can't really help you without being able to see the generated code or how it's pulled in |
...however Clippy does not honor the @generated and needs an explicit allow setting, see rust-lang/rust-clippy#702.
Rust-protobuf generates code with several clippy warnings. These warnings are hard to fix, they bother rust-protobuf users, and they actually do need to be fixed (because I know the code is correct).
So the best way to fix the issue in rust-protobuf with clippy would be probably to tell clippy to ignore all clippy warning in some file. However as I understand there is no way to do that.
Clippy could ignore files with comments like "this file is generated" or "ignore clippy".
Note that generated code must be valid even if clippy is not used.
The text was updated successfully, but these errors were encountered: