Skip to content

Itertools 0.13.0 breaks strum derive macros if both are in scope at the same time. #942

Closed
@VorpalBlade

Description

@VorpalBlade
// Uncomment this line and this fails to build (with itertools 0.13.0, works with 0.12.1)
// use itertools::Itertools;

#[derive(Debug, strum::EnumIter)]
enum A {
    B,
    C,
}

This leads to the very strange following error if the mentioned line is uncommented:

   Compiling itertools_strum v0.1.0 (/home/arvid/src/itertools_strum)
error[E0277]: the trait bound `usize: IteratorIndex<&mut AIter>` is not satisfied
   --> src/main.rs:4:17
    |
4   | #[derive(Debug, strum::EnumIter)]
    |                 ^^^^^^^^^^^^^^^ the trait `IteratorIndex<&mut AIter>` is not implemented for `usize`
    |
    = help: the following other types implement trait `IteratorIndex<I>`:
              RangeFull
              std::ops::Range<usize>
              RangeFrom<usize>
              RangeTo<usize>
              RangeInclusive<usize>
              RangeToInclusive<usize>
note: required by a bound in `itertools::Itertools::get`
   --> /home/arvid/.cargo/registry/src/index.crates.io-6f17d22bba15001f/itertools-0.13.0/src/lib.rs:554:12
    |
551 |     fn get<R>(self, index: R) -> R::Output
    |        --- required by a bound in this associated function
...
554 |         R: traits::IteratorIndex<Self>,
    |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `Itertools::get`
    = note: this error originates in the derive macro `strum::EnumIter` (in Nightly builds, run with -Z macro-backtrace for more info)

For more information about this error, try `rustc --explain E0277`.
error: could not compile `itertools_strum` (bin "itertools_strum") due to 2 previous errors

I have no idea if this is a strum or itertools bug. As such I have reported this to both, see Peternator7/strum#358

Using rustc 1.78.0 (9b00956e5 2024-04-29).

[dependencies]
itertools = "0.13.0"
strum = { version = "0.26.2", features = ["derive"] }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions