empty_enum_variants_with_brackets is arguably not redundant #12551
Labels
C-bug
Category: Clippy is not doing the correct thing
I-false-positive
Issue: The lint was triggered on code it shouldn't have
Description
I noticed that Clippy in Rust 1.77 includes a new lint
empty_enum_variants_with_brackets
(from #12047). The reasoning is that these are redundant.Functionally, sure. But there is a feature of Rust where tuple-like enum variants get a kind of static function generated as a constructor for them, so you can do things like this:
This is extremely contrived, yes, but illustrates that (a) not every enum with empty variants will have a natural
Default
implementation, and (b) removing the()
has effects outside of that change alone eg. any API requiring and receiving aFnOnce() -> Symbol
now has to be called with a closure (|| Symbol::Nothing
) or a static constructor has to be explicitly written.I do not have strong feelings about it, but I do use this sometimes and I wanted to raise it in case it hadn't been considered. (Ideally I'd like Rust to extend the automatic static constructor thing to any empty-equivalent enum variant ie.
Empty
,Empty()
,Empty(())
andEmpty {}
would all have it, but I'm not writing any RFCs any time soon.)Version
The text was updated successfully, but these errors were encountered: