You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Checks for usage of the #[allow] attribute and suggests replacing it with the #[expect] attribute (See RFC 2383)
#[expect] attributes suppress the lint emission, but emit a warning, if the expectation is unfulfilled. This can be useful to be notified when the lint is no longer triggered.
We have a quite a few occurrences of #[allow] in our codebase, but should prefer #[expect] instead for the reasons above.
Describe the solution you'd like
Similar to #18503 we should roll this lint our gradually through crates before finally enabling at the workspace level so we don't have one big PR.
Describe alternatives you've considered
Don't enable this lint if we don't see value or if the false positive rate is too high (see below).
Additional context
I tested it for some of our current #[allow]s and it has some false positives, especially for dead_code and deprecated.
/// create an in-memory table given the partition len, array len, and batch size,
/// and the result table will be of array_len in total, and then partitioned, and batched.
#[allow(dead_code)]
pubfncreate_table_provider(
If I switch this to #[expect(dead_code)] then clippy will flag it as this lint expectation is unfulfilled. But if I remove the lint then the dead code warning pops up anyway 🤔
/// Create a new [DiskManager] that creates temporary files within
/// a temporary directory chosen by the OS
#[default]
NewOs,
/// Create a new [DiskManager] that creates temporary files within
/// the specified directories
NewSpecified(Vec<PathBuf>),
/// Disable disk manager, attempts to create temporary files will error
Disabled,
}
Switching this to #[expect(deprecated)] causes similar to above, but also flags NewOS variant as using deprecated variant. Something to do with how Default is derived?
(I say false positive but it seems more like a bug in clippy 🤔)
Maybe there are solutions for the above, I haven't looked into it much yet.
Another thing to keep in mind is how features interact, for example here:
let object_meta = self.partitioned_file.object_meta.clone();
let metadata_cache = Arc::clone(&self.metadata_cache);
asyncmove{
#[cfg(feature = "parquet_encryption")]
let file_decryption_properties = options
.and_then(|o| o.file_decryption_properties())
.map(Arc::clone);
#[cfg(not(feature = "parquet_encryption"))]
let file_decryption_properties = None;
This #[allow] is for when parquet_encryption feature is not enabled, but if we change it to #[expect] blindly then I believe it'll cause issues when parquet_encryptionis enabled, so we need to be careful
Note: we would welcome PRs that can do multiple crates in a single PR (so long as the diff isn't too large). Felt a bit overwhelmed by the volume and speed of PRs that came in for #18503 😅
Is your feature request related to a problem or challenge?
Lint reference: https://rust-lang.github.io/rust-clippy/master/index.html?search=allow_att#allow_attributes
We have a quite a few occurrences of
#[allow]in our codebase, but should prefer#[expect]instead for the reasons above.Describe the solution you'd like
Similar to #18503 we should roll this lint our gradually through crates before finally enabling at the workspace level so we don't have one big PR.
Describe alternatives you've considered
Don't enable this lint if we don't see value or if the false positive rate is too high (see below).
Additional context
I tested it for some of our current
#[allow]s and it has some false positives, especially fordead_codeanddeprecated.Example 1
datafusion/datafusion/core/benches/data_utils/mod.rs
Lines 37 to 40 in c8d26ba
#[expect(dead_code)]then clippy will flag it asthis lint expectation is unfulfilled. But if I remove the lint then the dead code warning pops up anyway 🤔Example 2
datafusion/datafusion/execution/src/disk_manager.rs
Lines 117 to 136 in c8d26ba
#[expect(deprecated)]causes similar to above, but also flagsNewOSvariant as using deprecated variant. Something to do with howDefaultis derived?(I say false positive but it seems more like a bug in clippy 🤔)
Maybe there are solutions for the above, I haven't looked into it much yet.
Another thing to keep in mind is how features interact, for example here:
datafusion/datafusion/datasource-parquet/src/reader.rs
Lines 290 to 304 in c8d26ba
#[allow]is for whenparquet_encryptionfeature is not enabled, but if we change it to#[expect]blindly then I believe it'll cause issues whenparquet_encryptionis enabled, so we need to be carefulTasks
clippy::allow_attributesfor optimizer and macros #19310clippy::allow_attributesfor optimizer and macros #19310clippy::allow_attributesglobally across workspace #19576Note: we would welcome PRs that can do multiple crates in a single PR (so long as the diff isn't too large). Felt a bit overwhelmed by the volume and speed of PRs that came in for #18503 😅