Skip to content

Rust 1.20 regression, for_each 0.2.0, conflicts with unstable iterator_for_each feature #43239

Closed
@jdm

Description

@jdm
   Compiling foreach v0.2.0 (file:///Users/jdm/src/iter_foreach)
error: use of unstable library feature 'iterator_for_each' (see issue #42986)
  --> tests/basic.rs:10:10
   |
10 |     iter.for_each(|item, iter| {
   |          ^^^^^^^^
   |
   = help: add #![feature(iterator_for_each)] to the crate attributes to enable

error[E0593]: closure takes 2 arguments but 1 argument is required
  --> tests/basic.rs:10:10
   |
10 |       iter.for_each(|item, iter| {
   |  __________^^^^^^^^_-
   | |          |
   | |          expected closure that takes 1 argument
11 | |                       assert_eq!(item, i * 2);
12 | |                       i += 1;
13 | |                       let _ = iter.next();
14 | |                   });
   | |___________________- takes 2 arguments

error: aborting due to 2 previous errors

error: Could not compile `foreach`.
warning: build failed, waiting for other jobs to finish...
error: build failed

cc @JaJe

It appears that a new unstable feature was implemented that conflicts with the for_each crate. rustc interprets the use of Iterator::for_each as attempting to use the unstable feature instead of the trait method defined by the for_each crate.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.P-highHigh priorityT-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.regression-from-stable-to-betaPerformance or correctness regression from stable to beta.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions