How to prevent cargo clippy from analyizing generated prost files

1.1k views Asked by At

I am using prost to generate rust classes for protobufs. I want clippy to ignore these generated files and I'm having trouble figuring out how to make clippy ignore them.

In my lib.rs file, I have

pub mod modes {
    #[allow(clippy)]
    include!(concat!(env!("OUT_DIR"), "/modes.rs"));
}

#[allow(clippy)]
pub mod vehicle_features {
    include!(concat!(env!("OUT_DIR"), "/vehicle_features.rs"));
}

However, I still get clippy warnings for both the modes.rs and vehicle_features.rs files. How do I ignore these modules / files in clippy, without modifing the files at all.

EDIT: based on a below suggestion, I changed the code to read:

pub mod modes {
    #![allow(clippy::all)]
    include!(concat!(env!("OUT_DIR"), "/modes.rs"));
}

pub mod vehicle_features {
    #![allow(clippy::all)]
    include!(concat!(env!("OUT_DIR"), "/vehicle_features.rs"));
}

This works when running cargo clippy but not when running cargo clippy -- -W unwrap_used does anyone know why? How can I make it work when I add additional warning arguments to clippy?

EDIT2:

I found the answer here: How to disable a clippy lint for a single line / block?

"clippy:all doesn't actually allow all lints, rather everything contained by correctness, suspicious, style, complexity, cargo, and perf. This means no pedantic or nursery lints.."

So I had to add #![allow(clippy::all, clippy::pedantic, clippy::nursery)]

1

There are 1 answers

2
Chayim Friedman On

You need to allow clippy::all. #[allow(clippy::all)] outside the module, or #![allow(clippy::all)] inside it.