lloydmeta / frunk

Funktional generic type-level programming in Rust: HList, Coproduct, Generic, LabelledGeneric, Validated, Monoid and friends.
https://beachape.com/frunk/
MIT License
1.29k stars 58 forks source link

hlist_pat can trigger #[warn(non_shorthand_field_patterns)] #107

Closed ExpHP closed 6 years ago

ExpHP commented 6 years ago
let hlist_pat![head, ...tail] = list;
warning: the `head:` in this pattern is redundant
  --> src/main.rs:5:18
   |
5  |     => { HCons { head: $a, tail: $b }};
   |                  ^^^^ help: remove this
...
10 |     let hlist_pat!(head, tail) = list;
   |         ---------------------- in this macro invocation
   |
   = note: #[warn(non_shorthand_field_patterns)] on by default

warning: the `tail:` in this pattern is redundant
  --> src/main.rs:5:28
   |
5  |     => { HCons { head: $a, tail: $b }};
   |                            ^^^^ help: remove this
...
10 |     let hlist_pat!(head, tail) = list;
   |         ---------------------- in this macro invocation

    Finished dev [unoptimized + debuginfo] target(s) in 0.50 secs
     Running `target/debug/playground`

I don't see any solution so I opened this thread as a call for help.

lloydmeta commented 6 years ago

Nice; we'll see what the community says :)

ExpHP commented 6 years ago

So yesterday I tried working around this, and came to the conclusion that doing so is possible but outrageously difficult. I came to this conclusion when the macro was at a length of about 16 rules with a 150-line test suite, and was still incorrect for the edge case of [mut head, ...mut tail], which would have required rewriting the recursive case as an incremental muncher and doubling the size of the test suite.

https://github.com/rust-lang/rust/pull/49614 is coming to the rescue.

lloydmeta commented 6 years ago

rust-lang/rust#49614 is coming to the rescue.

Totally fine with waiting on that :)

ExpHP commented 6 years ago

Fixed as of rustc stable 1.28.0.