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

Get rid of the iter-trait hack #2827

Closed
msullivan opened this issue Jul 6, 2012 · 7 comments
Closed

Get rid of the iter-trait hack #2827

msullivan opened this issue Jul 6, 2012 · 7 comments
Labels
C-cleanup Category: PRs that clean code up or issues documenting cleanup.
Milestone

Comments

@msullivan
Copy link
Contributor

The iter-trait hack is really frumious. We have better ways to do it.

@ghost ghost assigned msullivan Jul 6, 2012
@msullivan
Copy link
Contributor Author

Argh. I refactored it to use another impl parameterized over anything implementing base_iter, but now type inference fails in a bunch of places with the type of this value must be known in this context errors.

@msullivan
Copy link
Contributor Author

I've fixed all of the bugs I thought were blocking this, and have been left with more fundamental issues.

I was trying to solve this by making an impl of ExtendedIter for all instances of BaseIter:

impl<A, I: BaseIter<A>> I: iter::ExtendedIter<A> {
...
}

This now sort of works. There are some big downsides, though, that all stem from the fact that all calls of methods in ExtendedIter will immediately resolve to this impl. This means that autoderef and implicit borrows won't work when calling these methods, since the original type will match, and it also means that no other trait or impl can use method names that are also used by ExtendedIter, since there will be multiple matching methods.

So I'm not going to finish fixing the things it breaks. I'm going to unassign myself.

The right way to get rid of this is going to be using default implementations as tracked in #2794.

@catamorphism
Copy link
Contributor

I tried fixing this bug, but I believe it's blocked on #3979:

pub trait ExtendedIter<A>: BaseIter<A> {
    pure fn eachi(blk: fn(uint, v: &A) -> bool) {
        eachi(&self, blk)
    }
   // etc.

(added to core::iter)

and I got:

iter.rs:32:8: 32:13 error: failed to find an implementation of trait @iter::BaseIter<<V2>> for <V3>
/Users/tchevalier/rust/src/libcore/iter.rs:32         eachi(&self, blk)

This resembles the behavior in #3979.

Bumping to 0.6

@catamorphism
Copy link
Contributor

Now that I have a fix for #3979, I'm working on this.

@ghost ghost assigned catamorphism Jan 19, 2013
@brson
Copy link
Contributor

brson commented Jan 20, 2013

The last time I tried I hit #4148

@catamorphism
Copy link
Contributor

Oh, yeah, I think I hit #4148 as well. I didn't realize at first what the issue was and now it's looking pretty intimidating.

@thestinger
Copy link
Contributor

The iter-trait stuff is gone now, and there are functions in the iter module that can be used with any type implementing BaseIter. It would be nice to have these as methods, but it would need to be possible to override a default implementation first.

RalfJung pushed a commit to RalfJung/rust that referenced this issue Apr 28, 2023
celinval added a commit to celinval/rust-dev that referenced this issue Jun 4, 2024
Update the CI to use MacOS 12 instead of MacOS 11. I'm leaving this as a
draft until I can validate that the bundle works on MacOS 11.

Resolves rust-lang#2827
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-cleanup Category: PRs that clean code up or issues documenting cleanup.
Projects
None yet
Development

No branches or pull requests

4 participants