Repository navigation
Fix preallocation amount in String::from_utf16 - #17752
Merged
Merged
Conversation
`v.len()` counts code units, not UTF-16 bytes. The lower bound is one UTF-8 byte per code unit, not per two code units.
Contributor
|
The lower bound is 1 byte per code unit since it could all be code units representing code points that UTF-8 covers with 1 byte. |
Contributor
Author
|
Yeah, that’s what I thought. |
bors
added a commit
that referenced
this pull request
Oct 4, 2014
`v.len()` counts code units, not UTF-16 bytes. The lower bound is one UTF-8 byte per code unit, not per two code units. I believe this is correct, but it’s late. Someone please double check.
flip1995
pushed a commit
to flip1995/rust
that referenced
this pull request
Sep 24, 2026
…g#17752) Implements part of rust-lang/rust-clippy#17485 Unleaking a leaked `Box` pointer isn't well defined, so we shouldn't be suggesting to change `into_raw` into `leak`. This needs to be backported to beta and ideally would be synced before a new beta is branched off. r? flip1995 changelog: [`nonnull_unchecked_on_box_ptr`]: Don't suggest `Box::leak`
Kobzol
pushed a commit
to Kobzol/rust
that referenced
this pull request
Sep 29, 2026
…g#17752) Implements part of rust-lang/rust-clippy#17485 Unleaking a leaked `Box` pointer isn't well defined, so we shouldn't be suggesting to change `into_raw` into `leak`. This needs to be backported to beta and ideally would be synced before a new beta is branched off. r? flip1995 changelog: [`nonnull_unchecked_on_box_ptr`]: Don't suggest `Box::leak`
flip1995
pushed a commit
to flip1995/rust
that referenced
this pull request
Oct 1, 2026
…g#17752) Implements part of rust-lang/rust-clippy#17485 Unleaking a leaked `Box` pointer isn't well defined, so we shouldn't be suggesting to change `into_raw` into `leak`. This needs to be backported to beta and ideally would be synced before a new beta is branched off. r? flip1995 changelog: [`nonnull_unchecked_on_box_ptr`]: Don't suggest `Box::leak`
JonathanBrouwer
pushed a commit
to JonathanBrouwer/rust
that referenced
this pull request
Nov 5, 2026
…g#17752) Implements part of rust-lang/rust-clippy#17485 Unleaking a leaked `Box` pointer isn't well defined, so we shouldn't be suggesting to change `into_raw` into `leak`. This needs to be backported to beta and ideally would be synced before a new beta is branched off. r? flip1995 changelog: [`nonnull_unchecked_on_box_ptr`]: Don't suggest `Box::leak`
JonathanBrouwer
pushed a commit
to JonathanBrouwer/rust
that referenced
this pull request
Nov 5, 2026
…g#17752) Implements part of rust-lang/rust-clippy#17485 Unleaking a leaked `Box` pointer isn't well defined, so we shouldn't be suggesting to change `into_raw` into `leak`. This needs to be backported to beta and ideally would be synced before a new beta is branched off. r? flip1995 changelog: [`nonnull_unchecked_on_box_ptr`]: Don't suggest `Box::leak`
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.
v.len()counts code units, not UTF-16 bytes. The lower bound is one UTF-8 byte per code unit, not per two code units.I believe this is correct, but it’s late. Someone please double check.