Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Itertools 0.13.0 and strum derive macro EnumIter break if both are used at the same time #358

Closed
VorpalBlade opened this issue May 20, 2024 · 2 comments · Fixed by #357
Closed

Comments

@VorpalBlade
Copy link

// 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 rust-itertools/itertools#942

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

[dependencies]
itertools = "0.13.0"
strum = { version = "0.26.2", features = ["derive"] }
@VorpalBlade
Copy link
Author

Apparently it is a macro hygiene issue on strum's side, where it should call get fully qualified instead.

@bluurryy
Copy link
Contributor

PR #357 fixes this.

joshka added a commit to joshka/strum that referenced this issue Jun 14, 2024
This is required for compatibility with itertools 0.13.0 fixed in Peternator7#358

Fixes: Peternator7#364
Peternator7 pushed a commit that referenced this issue Jun 23, 2024
This is required for compatibility with itertools 0.13.0 fixed in #358

Fixes: #364
zydou pushed a commit to zydou/arti that referenced this issue Jun 25, 2024
We're about to update to iterools 0.13.0.  We must therefore have a
version of strum which is not affected by
   Peternator7/strum#358

Precisely
  git-grep -l '^strum' | xargs perl -i~ -pe 's{"0\.26"}{"0.26.3"}'

No changes to lockfile - we're already using 0.26.3, except perhaps in
the minimal versions test.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants