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

Step::replace_one should put a one, not a zero (Issue #41492) #41493

Merged
merged 1 commit into from
Apr 27, 2017

Conversation

scottmcm
Copy link
Member

Turns out all six of the replace_* impls were backwards.

Turns out all six of these impls are incorrect.
@rust-highfive
Copy link
Collaborator

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @sfackler (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see the contribution instructions for more information.

@sfackler
Copy link
Member

I haven't really been following the Step trait design, but if these impls were this broken, it seems like the level of testing of that trait is pretty lacking.

@carols10cents
Copy link
Member

@sfackler there are some tests in this PR, are you asking for more tests? Just trying to understand what the next steps are on this PR :)

@carols10cents carols10cents added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Apr 24, 2017
@sfackler
Copy link
Member

I am trying to understand why these methods exist if no one has noticed for so long that they return the wrong value :)

@scottmcm
Copy link
Member Author

scottmcm commented Apr 25, 2017

For context, I encountered this trying to implement this proposal rust-lang/rfcs#1980 after the discussion in #28237 (comment).

As for why it wasn't noticed, it looks like std only uses it when producing a RangeInclusive::Empty, and apparently nobody ever cared about the value inside that. (Which I suppose is an interesting argument that the field in that variant is also useless.) Edit: actually, the only use is an implementation detail of StepBy<A, ops::RangeInclusive<A>>::next, which uses replace_zero but never actually exposes that zero.

I agree that the Step trait is sub-optimal, but that's already tracked by #27741. I'd propose making this fix and having the "do these methods make sense" discussion there.

@sfackler
Copy link
Member

This is certainly an improvement on the status quo

@bors r+

@bors
Copy link
Contributor

bors commented Apr 25, 2017

📌 Commit f8c6436 has been approved by sfackler

arielb1 pushed a commit to arielb1/rust that referenced this pull request Apr 25, 2017
Step::replace_one should put a one, not a zero (Issue rust-lang#41492)

Turns out all six of the replace_* impls were backwards.
arielb1 pushed a commit to arielb1/rust that referenced this pull request Apr 25, 2017
Step::replace_one should put a one, not a zero (Issue rust-lang#41492)

Turns out all six of the replace_* impls were backwards.
frewsxcv added a commit to frewsxcv/rust that referenced this pull request Apr 26, 2017
Step::replace_one should put a one, not a zero (Issue rust-lang#41492)

Turns out all six of the replace_* impls were backwards.
frewsxcv added a commit to frewsxcv/rust that referenced this pull request Apr 26, 2017
Step::replace_one should put a one, not a zero (Issue rust-lang#41492)

Turns out all six of the replace_* impls were backwards.
bors added a commit that referenced this pull request Apr 26, 2017
Rollup of 7 pull requests

- Successful merges: #41370, #41447, #41456, #41493, #41499, #41501, #41550
- Failed merges:
arielb1 pushed a commit to arielb1/rust that referenced this pull request Apr 26, 2017
Step::replace_one should put a one, not a zero (Issue rust-lang#41492)

Turns out all six of the replace_* impls were backwards.
arielb1 pushed a commit to arielb1/rust that referenced this pull request Apr 26, 2017
Step::replace_one should put a one, not a zero (Issue rust-lang#41492)

Turns out all six of the replace_* impls were backwards.
bors added a commit that referenced this pull request Apr 27, 2017
Rollup of 9 pull requests

- Successful merges: #41370, #41456, #41493, #41499, #41501, #41524, #41546, #41550, #41552
- Failed merges:
@bors bors merged commit f8c6436 into rust-lang:master Apr 27, 2017
@scottmcm scottmcm deleted the fix-step-replace branch April 27, 2017 03:28
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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants