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

Regression in BTreeMap iterator variance #30979

Closed
apasel422 opened this issue Jan 17, 2016 · 3 comments
Closed

Regression in BTreeMap iterator variance #30979

apasel422 opened this issue Jan 17, 2016 · 3 comments

Comments

@apasel422
Copy link
Contributor

#30426 caused btree_map::{IntoIter, Iter, Range} to become invariant in K and V. They were previously covariant.

CC #30642 @gankro @gereeter

@Gankra
Copy link
Contributor

Gankra commented Jan 17, 2016

Oops! I could've sworn we checked up on variance, but I guess these slipped through.

@gereeter
Copy link
Contributor

I checked for variance on BTreeMap itself, but forgot about the iterators.

@gereeter
Copy link
Contributor

This is actually annoyingly tricky, because the invariance comes from NodeRef, which is generic in mutability - NodeRef<Mut, K, V, Type> should be invariant in K and V, but I don't think that it is possibly to have the variance of one type parameter depend on another.

Probably the best option is to make NodeRef universally covariant, just adding invariance markers to RangeMut and IterMut.

bors added a commit that referenced this issue Jan 18, 2016
This takes the approach of making `NodeRef` universally covariant.

 Fixes #30979.
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

No branches or pull requests

3 participants