Skip to content

Deriving Sequence does not work for empty enums #16

@brkalmar

Description

@brkalmar
  • rust version: 1.62.0
  • enum-iterator version: 1.1.2

The documentation states that Sequence can be derived for "enumerations without variants".
However, this does not work.

Minimal example

use enum_iterator::Sequence;

#[derive(Sequence)]
enum Empty {}

Expected outcome

Sequence is successfully implemented for Empty.

Actual outcome

error[E0004]: non-exhaustive patterns: type `&Empty` is non-empty
 --> src/lib.rs:3:10
  |
3 | #[derive(Sequence)]
  |          ^^^^^^^^
  |
note: `Empty` defined here
 --> src/lib.rs:4:6
  |
4 | enum Empty {}
  |      ^^^^^
  = note: the matched value is of type `&Empty`
  = note: references are always considered inhabited
  = note: this error originates in the derive macro `Sequence` (in Nightly builds, run with -Z macro-backtrace for more info)
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern as shown
  |
3 ~ #[derive(Sequence {
4 +     _ => todo!(),
5 ~ })]
  |

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions