Skip to content

Range<u64> implements ExactSizeIterator #22047

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

Closed
bluss opened this issue Feb 7, 2015 · 2 comments · Fixed by #22299
Closed

Range<u64> implements ExactSizeIterator #22047

bluss opened this issue Feb 7, 2015 · 2 comments · Fixed by #22299

Comments

@bluss
Copy link
Member

bluss commented Feb 7, 2015

What does (0..std::u64::MAX).size_hint() return on a 32-bit build? Range<u64> and Range<i64> cannot fulfill the requirements of the ExactSizeIterator trait, and the implementations must be removed.

@sfackler sfackler added the A-libs label Feb 7, 2015
@bluss
Copy link
Member Author

bluss commented Feb 7, 2015

I checked the code and it turns out the impl is conditional -- only on 64-bit platforms. So that's correct and for me it turned into a different question of whether that kind of platform dependence is good. I've started a discussion about that here.

@bluss bluss closed this as completed Feb 7, 2015
@bluss bluss reopened this Feb 13, 2015
@bluss
Copy link
Member Author

bluss commented Feb 13, 2015

Reopened, got some voices backing that this is a bug.

Soft solution would be to warn on using that particular impl of ExactSizeIterator for Range and i64, but I don't know if we can even do that.

Otherwise we can just remove the impls.

bluss pushed a commit to bluss/rust that referenced this issue Feb 13, 2015
Fixes rust-lang#22047

Range<u64> and Range<i64> may be longer than usize::MAX on 32-bit
platforms, and thus they cannot fulfill the protocol for
ExactSizeIterator. We don't want a nonobvious platform dependency in
basic iterator traits, so the trait impl is removed.

The logic of this change assumes that usize is at least 32-bit.

This is technically a breaking change; note that Range<usize> and
Range<isize> are always ExactSizeIterators.

[breaking-change]
steveklabnik added a commit to steveklabnik/rust that referenced this issue Feb 14, 2015
…=alexcrichton

Fixes rust-lang#22047

Range<u64> and Range<i64> may be longer than usize::MAX on 32-bit
platforms, and thus they cannot fulfill the protocol for
ExactSizeIterator. We don't want a nonobvious platform dependency in
basic iterator traits, so the trait impl is removed.

The logic of this change assumes that usize is at least 32-bit.

This is technically a breaking change; note that Range<usize> and
Range<isize> are always ExactSizeIterators.

[breaking-change]
steveklabnik added a commit to steveklabnik/rust that referenced this issue Feb 15, 2015
…=alexcrichton

Fixes rust-lang#22047

`Range<u64>` and `Range<i64>` may be longer than usize::MAX on 32-bit
platforms, and thus they cannot fulfill the protocol for
ExactSizeIterator. We don't want a nonobvious platform dependency in
basic iterator traits, so the trait impl is removed.

The logic of this change assumes that usize is at least 32-bit.

This is technically a breaking change; note that `Range<usize>` and
`Range<isize>` are always ExactSizeIterators.

[breaking-change]
Manishearth added a commit to Manishearth/rust that referenced this issue Feb 15, 2015
…=alexcrichton

 Fixes rust-lang#22047

`Range<u64>` and `Range<i64>` may be longer than usize::MAX on 32-bit
platforms, and thus they cannot fulfill the protocol for
ExactSizeIterator. We don't want a nonobvious platform dependency in
basic iterator traits, so the trait impl is removed.

The logic of this change assumes that usize is at least 32-bit.

This is technically a breaking change; note that `Range<usize>` and
`Range<isize>` are always ExactSizeIterators.

[breaking-change]
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

Successfully merging a pull request may close this issue.

2 participants