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

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

Closed
jdm opened this Issue Jul 14, 2017 · 6 comments

Comments

Projects
None yet
6 participants
@jdm
Copy link
Contributor

jdm commented Jul 14, 2017

   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.

@oli-obk

This comment has been minimized.

Copy link
Contributor

oli-obk commented Jul 14, 2017

I think this is expected breakage, since you could use UFC syntax to call the method you mean. Otherwise we could never add new methods to any type or trait.

@cuviper

This comment has been minimized.

Copy link
Member

cuviper commented Jul 14, 2017

I'm surprised that it just assumes the code wanted Iterator::for_each, rather than reporting an ambiguity between that and ForEach::for_each. I thought only inherent methods took precedence like that. Is it because Iterator is in the prelude?

@sfackler

This comment has been minimized.

Copy link
Member

sfackler commented Jul 26, 2017

If iter is a generic T: Iterator or an &mut Iterator trait object, Iterator::for_each is treated somewhat inherently I believe. Seems like something's busted in the check if iter is a concrete type though.

@cuviper

This comment has been minimized.

Copy link
Member

cuviper commented Jul 26, 2017

In that test iter is a concrete type, a range.

@alexcrichton

This comment has been minimized.

Copy link
Member

alexcrichton commented Aug 1, 2017

The libs team decided to hold off on evaluating what to do here until we have a crater report to see what the brekage is.

@alexcrichton

This comment has been minimized.

Copy link
Member

alexcrichton commented Aug 12, 2017

A crater report for beta happened, and I don't believe we saw any other regressions related to this, so I'm going to close this now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.