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
Labels
C-bug Category: This is a bug. P-high High priority regression-from-stable-to-beta Performance or correctness regression from stable to beta. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.

Comments

@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.

@jdm jdm added the regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. label Jul 14, 2017
@oli-obk
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
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?

@alexcrichton alexcrichton added regression-from-stable-to-beta Performance or correctness regression from stable to beta. I-nominated T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. and removed regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. labels Jul 23, 2017
@sfackler
Copy link
Member

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
Copy link
Member

cuviper commented Jul 26, 2017

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

@Mark-Simulacrum Mark-Simulacrum added P-high High priority C-bug Category: This is a bug. labels Jul 27, 2017
@alexcrichton
Copy link
Member

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
Copy link
Member

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
Labels
C-bug Category: This is a bug. P-high High priority regression-from-stable-to-beta Performance or correctness regression from stable to beta. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

6 participants