vec: Fix size_hint() of reverse iterators#7565
Merged
thestinger merged 1 commit intorust-lang:masterfrom Jul 4, 2013
Blei:fix-rev-size-hint
Merged
vec: Fix size_hint() of reverse iterators#7565thestinger merged 1 commit intorust-lang:masterfrom Blei:fix-rev-size-hint
thestinger merged 1 commit intorust-lang:masterfrom
Blei:fix-rev-size-hint
Conversation
Member
|
There's also the separate problem of why does this fix the problem? Rust isn't a language that should segfault because of a bug in an implementation. Does this happen because a negative int is casted to an unsigned int? |
Contributor
|
@alexcrichton this testcase has a similar crash, no overflow checking in ~[]::reserve. |
Member
|
Yes, but I meant that this bug should be fixed as well as that one: #7578 |
thestinger
added a commit
that referenced
this pull request
Jul 4, 2013
vec: Fix size_hint() of reverse iterators
flip1995
pushed a commit
to flip1995/rust
that referenced
this pull request
Sep 3, 2021
New lint `manual_split_once` This is a WIP because it still needs to recognize more patterns. Currently handles: ```rust s.splitn(2, ' ').next(); s.splitn(2, ' ').nth(0) s.splitn(2, ' ').nth(1); s.splitn(2, ' ').skip(0).next(); s.splitn(2, ' ').skip(1).next(); s.splitn(2, ' ').next_tuple(); // from itertools // as well as `unwrap()` and `?` forms ``` Still to do: ```rust let mut iter = s.splitn(2, ' '); (iter.next().unwrap(), iter.next()?) let mut iter = s.splitn(2, ' '); let key = iter.next().unwrap(); let value = iter.next()?; ``` Suggestions on other patterns to check for would be useful. I've done a search on github for uses of `splitn`. Still have yet to actually look through the results. There's also the question of whether the lint shouold trigger on all uses of `splitn` with two values, or only on recognized usages. The former could have false positives where it couldn't be replaced, but I'm not sure how common that would be. changelog: Add lint `manual_split_once`
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #7558