#[warn(non_shorthand_field_patterns)] is a menace to pattern macros #49588
Labels
A-diagnostics
Area: Messages for errors, warnings, and lints
A-macros
Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..)
C-enhancement
Category: An issue proposing an enhancement or a PR with one.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
Nobody responded to my URLO thread, and the rabbit hole has only gotten deeper and deeper since I've started trying to work around this in frunk's hlist_pat. It's time for an issue.
Here's a simple pattern macro:
Trouble is, suppose somebody writes
pat!(value)
. Then they'll get this:Here is the simplest alternative I can come up with for working around this warning in this simple macro.
Notice how proper support for
ref
andmut
requires that the macro output uses shorthand field syntax, as opposed to a more scalable workaround likevalue: value@_
(where thevalue@_
is at least something that could be produced by a helper macro). A similar pattern macro for a struct with two fields basically requires an incremental muncher now, just to avoid the exponential blowup of5^n
rules.This is an awful lot of headache just for a little reminder to write more idiomatic code! Isn't that clippy's job, anyhow?
The text was updated successfully, but these errors were encountered: