Warning
This post was published 71 days ago. The information described in this article may have changed.
I'm thinking about trying to contribute a new feature, and I wanted to ask if it makes sense.
The idea is to create a new opt-in (allow by default) lint for unused public items. Just like unused_items
, but for the purpose of opting in for specific items or modules, in circumstances where the items should generally only be constructed by the crate.
For example, for use in bespoke error enums:
#[warn(unused_public_items)]
#[derive(Error, Debug)]
pub enum FunctionSpecificError {
#[error("All good here")]
VariantThatIsUsed
#[error("I would be caught by the lint")]
VariantThatIsntUsed
}
pub fn foo() -> Result<(), FunctionSpecificError> {
Err(FunctionSpecificError::VariantThatIsUsed)
}
Does this make sense to add? I would love to use this for my own stuff. Would it make sense as a compiler lint or a clippy lint? Thanks for your feedback.
1 post - 1 participant
🏷️ rust_feed