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

Implement more ExactSizeIterators on 64-bit platforms #124056

Closed
wants to merge 1 commit into from
Closed

Implement more ExactSizeIterators on 64-bit platforms #124056

wants to merge 1 commit into from

Conversation

yhx-12243
Copy link

In 64-bit platforms Range<i64>, Range<u64>, RangeInclusive<i32> and RangeInclusive<u32> should implement ExactSizeIterator.

@rustbot
Copy link
Collaborator

rustbot commented Apr 17, 2024

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @scottmcm (or someone else) some time within the next two weeks.

Please see the contribution instructions for more information. Namely, in order to ensure the minimum review times lag, PR authors and assigned reviewers should ensure that the review label (S-waiting-on-review and S-waiting-on-author) stays updated, invoking these commands when appropriate:

  • @rustbot author: the review is finished, PR author should check the comments and take action accordingly
  • @rustbot review: the author is ready for a review, this PR will be queued again in the reviewer's queue

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Apr 17, 2024
@rust-log-analyzer
Copy link
Collaborator

The job x86_64-gnu-tools failed! Check out the build log: (web) (plain)

Click to see the possible cause of the failure (guessed by this bot)
   Compiling getopts v0.2.21
error[E0034]: multiple applicable items in scope
    --> /cargo/registry/src/index.crates.io-6f17d22bba15001f/rustc-rayon-0.5.0/src/range.rs:256:44
     |
219  | / macro_rules! unindexed_range_impl {
220  | |     ( $t:ty, $len_t:ty ) => {
221  | |         impl UnindexedRangeLen<$len_t> for Range<$t> {
222  | |             fn len(&self) -> $len_t {
...    |
256  | |                 usize::try_from(iter.range.len()).ok()
     | |                                            ^^^ multiple `len` found
282  | |     };
283  | | }
     | |_- in this expansion of `unindexed_range_impl!`
...
...
296  |   unindexed_range_impl! {u64, u64}
     |
     |
note: candidate #1 is defined in an impl of the trait `UnindexedRangeLen` for the type `std::ops::Range<u64>`
     |
219  | / macro_rules! unindexed_range_impl {
219  | / macro_rules! unindexed_range_impl {
220  | |     ( $t:ty, $len_t:ty ) => {
221  | |         impl UnindexedRangeLen<$len_t> for Range<$t> {
222  | |             fn len(&self) -> $len_t {
...    |
282  | |     };
283  | | }
     | |_- in this expansion of `unindexed_range_impl!`
     | |_- in this expansion of `unindexed_range_impl!`
...
296  |   unindexed_range_impl! {u64, u64}
     = note: candidate #2 is defined in an impl of the trait `ExactSizeIterator` for the type `std::ops::Range<u64>`
     = note: candidate #2 is defined in an impl of the trait `ExactSizeIterator` for the type `std::ops::Range<u64>`
note: candidate #3 is defined in the trait `iter::IndexedParallelIterator`
     |
3111 |     fn len(&self) -> usize;
     |     ^^^^^^^^^^^^^^^^^^^^^^^
help: disambiguate the method for candidate #1
help: disambiguate the method for candidate #1
     |
256  |                 usize::try_from(UnindexedRangeLen::len(&iter.range)).ok()
help: disambiguate the method for candidate #2
     |
     |
256  |                 usize::try_from(ExactSizeIterator::len(&iter.range)).ok()
help: disambiguate the method for candidate #3
     |
     |
256  |                 usize::try_from(iter::IndexedParallelIterator::len(&iter.range)).ok()

error[E0034]: multiple applicable items in scope
    --> /cargo/registry/src/index.crates.io-6f17d22bba15001f/rustc-rayon-0.5.0/src/range.rs:264:40
     |
     |
219  | / macro_rules! unindexed_range_impl {
220  | |     ( $t:ty, $len_t:ty ) => {
221  | |         impl UnindexedRangeLen<$len_t> for Range<$t> {
222  | |             fn len(&self) -> $len_t {
...    |
264  | |                 let index = self.range.len() / 2;
     | |                                        ^^^ multiple `len` found
282  | |     };
283  | | }
     | |_- in this expansion of `unindexed_range_impl!`
...
...
296  |   unindexed_range_impl! {u64, u64}
     |
     |
note: candidate #1 is defined in an impl of the trait `UnindexedRangeLen` for the type `std::ops::Range<u64>`
     |
219  | / macro_rules! unindexed_range_impl {
219  | / macro_rules! unindexed_range_impl {
220  | |     ( $t:ty, $len_t:ty ) => {
221  | |         impl UnindexedRangeLen<$len_t> for Range<$t> {
222  | |             fn len(&self) -> $len_t {
...    |
282  | |     };
283  | | }
     | |_- in this expansion of `unindexed_range_impl!`
     | |_- in this expansion of `unindexed_range_impl!`
...
296  |   unindexed_range_impl! {u64, u64}
     = note: candidate #2 is defined in an impl of the trait `ExactSizeIterator` for the type `std::ops::Range<u64>`
     = note: candidate #2 is defined in an impl of the trait `ExactSizeIterator` for the type `std::ops::Range<u64>`
note: candidate #3 is defined in the trait `iter::IndexedParallelIterator`
     |
3111 |     fn len(&self) -> usize;
     |     ^^^^^^^^^^^^^^^^^^^^^^^
help: disambiguate the method for candidate #1
help: disambiguate the method for candidate #1
     |
264  |                 let index = UnindexedRangeLen::len(&self.range) / 2;
help: disambiguate the method for candidate #2
     |
     |
264  |                 let index = ExactSizeIterator::len(&self.range) / 2;
help: disambiguate the method for candidate #3
     |
     |
264  |                 let index = iter::IndexedParallelIterator::len(&self.range) / 2;

error[E0034]: multiple applicable items in scope
    --> /cargo/registry/src/index.crates.io-6f17d22bba15001f/rustc-rayon-0.5.0/src/range.rs:256:44
     |
     |
219  | / macro_rules! unindexed_range_impl {
220  | |     ( $t:ty, $len_t:ty ) => {
221  | |         impl UnindexedRangeLen<$len_t> for Range<$t> {
222  | |             fn len(&self) -> $len_t {
...    |
256  | |                 usize::try_from(iter.range.len()).ok()
     | |                                            ^^^ multiple `len` found
282  | |     };
283  | | }
     | |_- in this expansion of `unindexed_range_impl!`
...
...
297  |   unindexed_range_impl! {i64, u64}
     |
     |
note: candidate #1 is defined in an impl of the trait `UnindexedRangeLen` for the type `std::ops::Range<i64>`
     |
219  | / macro_rules! unindexed_range_impl {
219  | / macro_rules! unindexed_range_impl {
220  | |     ( $t:ty, $len_t:ty ) => {
221  | |         impl UnindexedRangeLen<$len_t> for Range<$t> {
222  | |             fn len(&self) -> $len_t {
...    |
282  | |     };
283  | | }
     | |_- in this expansion of `unindexed_range_impl!`
     | |_- in this expansion of `unindexed_range_impl!`
...
297  |   unindexed_range_impl! {i64, u64}
     |   -------------------------------- in this macro invocation
     = note: candidate #2 is defined in an impl of the trait `ExactSizeIterator` for the type `std::ops::Range<i64>`
note: candidate #3 is defined in the trait `iter::IndexedParallelIterator`
     |
3111 |     fn len(&self) -> usize;
     |     ^^^^^^^^^^^^^^^^^^^^^^^
help: disambiguate the method for candidate #1
help: disambiguate the method for candidate #1
     |
256  |                 usize::try_from(UnindexedRangeLen::len(&iter.range)).ok()
help: disambiguate the method for candidate #2
     |
     |
256  |                 usize::try_from(ExactSizeIterator::len(&iter.range)).ok()
help: disambiguate the method for candidate #3
     |
     |
256  |                 usize::try_from(iter::IndexedParallelIterator::len(&iter.range)).ok()

   Compiling memoffset v0.9.1
   Compiling rustc_apfloat v0.2.0+llvm-462a31f5a5ab
error[E0034]: multiple applicable items in scope
error[E0034]: multiple applicable items in scope
    --> /cargo/registry/src/index.crates.io-6f17d22bba15001f/rustc-rayon-0.5.0/src/range.rs:264:40
     |
219  | / macro_rules! unindexed_range_impl {
220  | |     ( $t:ty, $len_t:ty ) => {
221  | |         impl UnindexedRangeLen<$len_t> for Range<$t> {
222  | |             fn len(&self) -> $len_t {
...    |
264  | |                 let index = self.range.len() / 2;
     | |                                        ^^^ multiple `len` found
282  | |     };
283  | | }
     | |_- in this expansion of `unindexed_range_impl!`
...
...
297  |   unindexed_range_impl! {i64, u64}
     |
     |
note: candidate #1 is defined in an impl of the trait `UnindexedRangeLen` for the type `std::ops::Range<i64>`
     |
219  | / macro_rules! unindexed_range_impl {
219  | / macro_rules! unindexed_range_impl {
220  | |     ( $t:ty, $len_t:ty ) => {
221  | |         impl UnindexedRangeLen<$len_t> for Range<$t> {
222  | |             fn len(&self) -> $len_t {
...    |
282  | |     };
283  | | }
     | |_- in this expansion of `unindexed_range_impl!`
     | |_- in this expansion of `unindexed_range_impl!`
...
297  |   unindexed_range_impl! {i64, u64}
     |   -------------------------------- in this macro invocation
     = note: candidate #2 is defined in an impl of the trait `ExactSizeIterator` for the type `std::ops::Range<i64>`
note: candidate #3 is defined in the trait `iter::IndexedParallelIterator`
     |
3111 |     fn len(&self) -> usize;
     |     ^^^^^^^^^^^^^^^^^^^^^^^
help: disambiguate the method for candidate #1
help: disambiguate the method for candidate #1
     |
264  |                 let index = UnindexedRangeLen::len(&self.range) / 2;
help: disambiguate the method for candidate #2
     |
     |
264  |                 let index = ExactSizeIterator::len(&self.range) / 2;
help: disambiguate the method for candidate #3
     |
     |
264  |                 let index = iter::IndexedParallelIterator::len(&self.range) / 2;

   Compiling rustc_version v0.4.0
   Compiling datafrog v2.0.1
   Compiling bitflags v1.3.2

@yhx-12243
Copy link
Author

yhx-12243 commented Apr 17, 2024

This will partially affect
https://github.com/rust-lang/rustc-rayon/blob/f192a484741522bccb411cb5f1da9ec9577d6e27/src/range.rs#L296-L299
I think it should become a issue (feature request) now.

@Noratrieb
Copy link
Member

we generally want to avoid such portability surprises like this would introduce

@scottmcm
Copy link
Member

Adding these would be a pretty substantial policy change, so it's not something I can just decide in a PR.

Please open an API Change Proposal for libs-api to consider if you wish to do this, but for now I'm going to close the PR.

I suspect it's more likely that the way forward here (if anything) is something like what's described in #41619 (comment) , and not something based on conditional compilation cfgs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants