Skip to content

Conversation

scottmcm
Copy link
Member

Follow-up to #41439 (comment)

While doing so, remove the now-unused step, steps_between, and is_negative methods from Step.

Mostly simple, but needed two interesting changes:

  • Override Iterator::size_hint for iter::StepBy (so hints aren't lost)
  • Override Iterator::size_hint for ops::RangeFrom (so (0..).size_hint() returns what (0..).step_by(1).size_hint() used to)

(It turns out that (0..).step_by(d) is used in a bunch of tests, from cycle to vec_deque.)

Incidentally fixes #41477

Follow-up to rust-lang#41439 (comment)

While doing so, remove the now-unused `step`, `steps_between`, and `is_negative` methods from `Step`.

Mostly simple, but needed two interesting changes:
* Override `Iterator::size_hint` for `iter::StepBy` (so hints aren't lost)
* Override `Iterator::size_hint` for `ops::RangeFrom` (so `(0..).size_hint()` returns what `(0..).step_by(1).size_hint()` used to)
(It turns out that `(0..).step_by(d)` is used in a bunch of tests, from `cycle` to `vec_deque`.)

Incidentally fixes rust-lang#41477
@rust-highfive
Copy link
Contributor

r? @alexcrichton

(rust_highfive has picked a reviewer for you, use r? to override)

@Mark-Simulacrum Mark-Simulacrum added the S-waiting-on-crater Status: Waiting on a crater run to be completed. label May 20, 2017
@Mark-Simulacrum
Copy link
Member

Marking as needing crater, since we could potentially break a lot of crates with this change. cc @brson, @eddyb

@@ -199,7 +199,6 @@
- [sort_internals](library-features/sort-internals.md)
- [sort_unstable](library-features/sort-unstable.md)
- [splice](library-features/splice.md)
- [step_by](library-features/step-by.md)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm... The iterator_step_by entry is missing from this list. Do you mind adding it, please? 😃

@ivandardi
Copy link
Contributor

The current StepBy (in src/libcore/iter/mod.rs) description is An iterator that steps by n elements every iteration. It's badly worded (by me, sorry), and I think reusing the old range::StepBy description, but adapted, works better: An adapter for stepping iterators by a custom amount.. Could you please change that?

@Mark-Simulacrum Mark-Simulacrum added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label May 20, 2017
@scottmcm
Copy link
Member Author

Updated with @ivandardi's suggestions.

Crater is a good point. If it would help, I could split this into sequential PRs:

  1. Add the size_hint overrides: non-breaking
  2. Make Range::step_by redirect to Iterator::step_by, and alias the type: catches the interesting breaks in the parameter type change from T to usize
  3. Remove the now-unused methods on Step: breaking for implementors
  4. Actually remove the old step_by methods, type, and feature: breaking, but mechanical to fix

@alexcrichton
Copy link
Member

Thanks for the PR @scottmcm! Just to make sure I understand the current state of affairs:

If that's true, then I've got a few questions:

  • Everything here is unstable, right? How come we need crater?
  • Do you know what the remaining users of the Step trait are? If so, can you summarize them?

@scottmcm
Copy link
Member Author

@alexcrichton Yup, that's the state of things.

Everything here is unstable, right? How come we need crater?

I guess a better statement is that this is a removal of a fairly old feature, so it might be worth thinking about the impact even though it's only to nightly. But we probably don't need the certainty of a crater run, a GitHub search is likely sufficient.

Is there a general preference between a breaking change going under a new feature (so the error is up-front and there's something to search) or re-using the existing feature (so basic but common uses -- here step_by a positive literal -- just continue to work)?

Do you know what the remaining users of the Step trait are? If so, can you summarize them?

It's still used for

impl<A: Step> Iterator for ops::Range<A>
impl<A: Step> Iterator for ops::RangeFrom<A>
impl<A: Step> Iterator for ops::RangeInclusive<A>

(and all the more-specific iterators as well)

I think the best thing to do with Step is move it to a different tracking issue from step_by, since the trait is irrelevant to stabilizing the new method.

@alexcrichton
Copy link
Member

Ok cool, thanks for the clarifications! We historically have had a process around removing deprecated features from the standard library: (a) add a replacement (b) deprecate an api (c) wait a cycle and (d) delete the api. Nowadays though the amount of widely-used unstable apis in libstd seems to have drastically diminished so such a process may not be so required any more.

In that sense a breaking change could be ok here if there's not a whole lot of users, but if there's a lot of users we may wish for a cycle of deprecation before removal. Does that make sense?

@scottmcm
Copy link
Member Author

That makes sense. Thanks for the advice; I just got too excited at deleting stuff 🙂

I'll close this and open some new, smaller PRs.

@scottmcm scottmcm closed this May 23, 2017
Mark-Simulacrum added a commit to Mark-Simulacrum/rust that referenced this pull request May 23, 2017
…excrichton

Override size_hint and propagate ExactSizeIterator for iter::StepBy

Generally useful, but also a prerequisite for moving a bunch of unit tests off `Range*::step_by`.

A small non-breaking subset of rust-lang#42110 (which I closed).

Includes two small documentation changes @ivandardi requested on that PR.

r? @alexcrichton
Mark-Simulacrum added a commit to Mark-Simulacrum/rust that referenced this pull request May 23, 2017
…excrichton

Give step_trait a distinct tracking issue from step_by

iterator_step_by has decoupled their futures, so the tracking issue should split.

Old issue: rust-lang#27741
New issue: rust-lang#42168

r? @alexcrichton (another follow-up to closed PR rust-lang#42110 (comment))
frewsxcv added a commit to frewsxcv/rust that referenced this pull request May 24, 2017
…excrichton

Give step_trait a distinct tracking issue from step_by

iterator_step_by has decoupled their futures, so the tracking issue should split.

Old issue: rust-lang#27741
New issue: rust-lang#42168

r? @alexcrichton (another follow-up to closed PR rust-lang#42110 (comment))
frewsxcv added a commit to frewsxcv/rust that referenced this pull request May 24, 2017
…excrichton

Give step_trait a distinct tracking issue from step_by

iterator_step_by has decoupled their futures, so the tracking issue should split.

Old issue: rust-lang#27741
New issue: rust-lang#42168

r? @alexcrichton (another follow-up to closed PR rust-lang#42110 (comment))
Mark-Simulacrum added a commit to Mark-Simulacrum/rust that referenced this pull request May 24, 2017
…excrichton

Override size_hint and propagate ExactSizeIterator for iter::StepBy

Generally useful, but also a prerequisite for moving a bunch of unit tests off `Range*::step_by`.

A small non-breaking subset of rust-lang#42110 (which I closed).

Includes two small documentation changes @ivandardi requested on that PR.

r? @alexcrichton
Mark-Simulacrum added a commit to Mark-Simulacrum/rust that referenced this pull request May 26, 2017
…excrichton

Override size_hint and propagate ExactSizeIterator for iter::StepBy

Generally useful, but also a prerequisite for moving a bunch of unit tests off `Range*::step_by`.

A small non-breaking subset of rust-lang#42110 (which I closed).

Includes two small documentation changes @ivandardi requested on that PR.

r? @alexcrichton
Mark-Simulacrum added a commit to Mark-Simulacrum/rust that referenced this pull request May 26, 2017
…excrichton

Give step_trait a distinct tracking issue from step_by

iterator_step_by has decoupled their futures, so the tracking issue should split.

Old issue: rust-lang#27741
New issue: rust-lang#42168

r? @alexcrichton (another follow-up to closed PR rust-lang#42110 (comment))
frewsxcv added a commit to frewsxcv/rust that referenced this pull request May 26, 2017
…excrichton

Give step_trait a distinct tracking issue from step_by

iterator_step_by has decoupled their futures, so the tracking issue should split.

Old issue: rust-lang#27741
New issue: rust-lang#42168

r? @alexcrichton (another follow-up to closed PR rust-lang#42110 (comment))
frewsxcv added a commit to frewsxcv/rust that referenced this pull request May 26, 2017
…excrichton

Give step_trait a distinct tracking issue from step_by

iterator_step_by has decoupled their futures, so the tracking issue should split.

Old issue: rust-lang#27741
New issue: rust-lang#42168

r? @alexcrichton (another follow-up to closed PR rust-lang#42110 (comment))
Mark-Simulacrum added a commit to Mark-Simulacrum/rust that referenced this pull request May 26, 2017
…ed-tail, r=eddyb

extend `struct_tail` to operate over closures

Not 100% sure why this got exposed when it wasn't before, but this struct definitely seems wrong.

Fixes rust-lang#42110

r? @eddyb
Mark-Simulacrum added a commit to Mark-Simulacrum/rust that referenced this pull request May 27, 2017
…excrichton

Override size_hint and propagate ExactSizeIterator for iter::StepBy

Generally useful, but also a prerequisite for moving a bunch of unit tests off `Range*::step_by`.

A small non-breaking subset of rust-lang#42110 (which I closed).

Includes two small documentation changes @ivandardi requested on that PR.

r? @alexcrichton
Mark-Simulacrum added a commit to Mark-Simulacrum/rust that referenced this pull request May 27, 2017
…ed-tail, r=eddyb

extend `struct_tail` to operate over tuples

Not 100% sure why this got exposed when it wasn't before, but this struct definitely seems wrong.

Fixes rust-lang#42110

r? @eddyb
Mark-Simulacrum added a commit to Mark-Simulacrum/rust that referenced this pull request May 27, 2017
…excrichton

Override size_hint and propagate ExactSizeIterator for iter::StepBy

Generally useful, but also a prerequisite for moving a bunch of unit tests off `Range*::step_by`.

A small non-breaking subset of rust-lang#42110 (which I closed).

Includes two small documentation changes @ivandardi requested on that PR.

r? @alexcrichton
Mark-Simulacrum added a commit to Mark-Simulacrum/rust that referenced this pull request May 27, 2017
…ed-tail, r=eddyb

extend `struct_tail` to operate over tuples

Not 100% sure why this got exposed when it wasn't before, but this struct definitely seems wrong.

Fixes rust-lang#42110

r? @eddyb
Mark-Simulacrum added a commit to Mark-Simulacrum/rust that referenced this pull request May 28, 2017
…ed-tail, r=eddyb

extend `struct_tail` to operate over tuples

Not 100% sure why this got exposed when it wasn't before, but this struct definitely seems wrong.

Fixes rust-lang#42110

r? @eddyb
Mark-Simulacrum added a commit to Mark-Simulacrum/rust that referenced this pull request May 28, 2017
…ed-tail, r=eddyb

extend `struct_tail` to operate over tuples

Not 100% sure why this got exposed when it wasn't before, but this struct definitely seems wrong.

Fixes rust-lang#42110

r? @eddyb
bors added a commit that referenced this pull request May 28, 2017
Override size_hint and propagate ExactSizeIterator for iter::StepBy

Generally useful, but also a prerequisite for moving a bunch of unit tests off `Range*::step_by`.

A small non-breaking subset of #42110 (which I closed).

Includes two small documentation changes @ivandardi requested on that PR.

r? @alexcrichton
Mark-Simulacrum added a commit to Mark-Simulacrum/rust that referenced this pull request Jun 1, 2017
…alexcrichton

Deprecate range-specific `step_by`

Deprecation attributes and test updates only.

Was replaced by an any-iterator version in rust-lang#41439

Last follow-up (this release) to rust-lang#42110 (comment)

r? @alexcrichton
Mark-Simulacrum added a commit to Mark-Simulacrum/rust that referenced this pull request Jun 1, 2017
…alexcrichton

Deprecate range-specific `step_by`

Deprecation attributes and test updates only.

Was replaced by an any-iterator version in rust-lang#41439

Last follow-up (this release) to rust-lang#42110 (comment)

r? @alexcrichton
Mark-Simulacrum added a commit to Mark-Simulacrum/rust that referenced this pull request Jun 2, 2017
…alexcrichton

Deprecate range-specific `step_by`

Deprecation attributes and test updates only.

Was replaced by an any-iterator version in rust-lang#41439

Last follow-up (this release) to rust-lang#42110 (comment)

r? @alexcrichton
Mark-Simulacrum added a commit to Mark-Simulacrum/rust that referenced this pull request Jun 2, 2017
…alexcrichton

Deprecate range-specific `step_by`

Deprecation attributes and test updates only.

Was replaced by an any-iterator version in rust-lang#41439

Last follow-up (this release) to rust-lang#42110 (comment)

r? @alexcrichton
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-crater Status: Waiting on a crater run to be completed. S-waiting-on-review Status: Awaiting review from the assignee but also interested parties.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Incorrect lower bound from StepBy<A, RangeInclusive<A>>::size_hint
5 participants