Skip to content

Clean revert of recent String::retain changes - #166011

Merged
rust-bors[bot] merged 3 commits into
rust-lang:mainfrom
workingjubilee:clean-revert-string-retain
Nov 16, 2026
Merged

rust-bors[bot] merged 3 commits into
rust-lang:mainfrom
workingjubilee:clean-revert-string-retain

Conversation

@workingjubilee

@workingjubilee workingjubilee commented Nov 15, 2026 •

Copy link
Copy Markdown
Member

View all comments

Cleanly revert String::retain changes introduced in #150067 by also rolling back #163624's safety hygiene changes in order to address a performance regression in this function that was reported to us in #165988.

While we desire the safety-improving code, that code does not affect the risk of "actual" undefined behavior in the library code. It merely reduces the amount of implementation details we internally rely on and thus whether that code is resilient to changes around it.

r? @hanna-kruppe

@rustbot rustbot added the A-str Area: `str` and `String` label Nov 15, 2026
@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 Nov 15, 2026
@rustbot

rustbot commented Nov 15, 2026

Copy link
Copy Markdown
Collaborator

hanna-kruppe is currently at their maximum review capacity.
They may take a while to respond.

@rustbot

This comment has been minimized.

@workingjubilee

workingjubilee commented Nov 15, 2026 •

Copy link
Copy Markdown
Member Author

addressed rustbot's comment about the commit messages.

@rust-log-analyzer

This comment has been minimized.

unsafe { self.s.vec.set_len(self.write) }
let new_len = self.idx - self.del_bytes;
debug_assert!(new_len <= self.s.len());
unsafe { self.s.vec.set_len(new_len) };

@asder8215 asder8215 Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This needs a safety comment. I forgot to mention that I introduced that in my reversion since it didn't have one before and tidy complained about it.

View changes since the review

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

For the purpose of the revert, I would also accept // ignore-tidy-undocumented-unsafe. Not worth spending much time writing an actually good safety comment if this line will soon be replaced again.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I bothered to reapply the same safety comment verbatim with proper attribution and everything.

@hanna-kruppe

hanna-kruppe commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

The reverts themselves LGTM. It's a bit annoying that rustbot won't let us follow our usual guidance about commit messages in reverts. I guess you could write the PR references as "PR NNNN" or as rust-lang/rust#NNNN if you want to leave a better paper trail.

r=me after fixing tidy

@workingjubilee

Copy link
Copy Markdown
Member Author

Ah, undoc unsafe.

@workingjubilee
workingjubilee force-pushed the clean-revert-string-retain branch from a633ce8 to 191e1c3 Compare November 15, 2026 22:09
@rustbot

This comment was marked as resolved.

@workingjubilee

Copy link
Copy Markdown
Member Author

...ah, that won't allow working around it.

workingjubilee and others added 3 commits November 15, 2026 14:10
This reverts commit 3686046, reversing
changes made to b222250.
This reverts commit 35df304, reversing
changes made to e081d66.
Co-authored-by: Jubilee Young <workingjubilee@gmail.com>
@workingjubilee
workingjubilee force-pushed the clean-revert-string-retain branch from 191e1c3 to 08e44b1 Compare November 15, 2026 22:10
@workingjubilee

workingjubilee commented Nov 15, 2026 •

Copy link
Copy Markdown
Member Author

Briefly tried to squirm around rustbot's demands before giving up and going back on the revert commits. New commit is just the same SAFETY doc as was previously introduced in the reverted commits.

@hanna-kruppe

Copy link
Copy Markdown
Contributor

@bors r+ rollup

@rust-bors

rust-bors Bot commented Nov 15, 2026

Copy link
Copy Markdown
Contributor

📌 Commit 08e44b1 has been tentatively approved by hanna-kruppe

It will be put into the queue for this repository once PR CI succeeds.

🌲 The tree is currently closed for pull requests below priority 5. This pull request will be tested once the tree is reopened.

@rust-bors rust-bors Bot added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Nov 15, 2026
@hanna-kruppe hanna-kruppe added the beta-nominated Nominated for backporting to the compiler in the beta channel. label Nov 15, 2026
@hanna-kruppe

Copy link
Copy Markdown
Contributor

Briefly hesitated about rollup because this revert is aimed at fixing a perf regression, but it wasn't a rustc-perf regression, so should be fine. But maybe @bors rollup=maybe is more sensible.

@workingjubilee

Copy link
Copy Markdown
Member Author

nowadays we're more eager about rolling up perf changes anyways.

@hanna-kruppe

hanna-kruppe commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

I will remain perfectly neutral about that and leave it to the judgement of the people creating rollups :)

@clarfonthey

clarfonthey commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

@bors r=hanna-kruppe rollup=iffy note="perf-sensitive, but not rustc-perf sensitive"

(mostly just because I know otherwise it might not show up on the queue correctly)

@rust-bors

rust-bors Bot commented Nov 15, 2026

Copy link
Copy Markdown
Contributor

📌 Commit 08e44b1 has been tentatively approved by hanna-kruppe

It will be put into the queue for this repository once PR CI succeeds.

🌲 The tree is currently closed for pull requests below priority 5. This pull request will be tested once the tree is reopened.

jhpratt added a commit to jhpratt/rust that referenced this pull request Nov 16, 2026
…-retain, r=hanna-kruppe

Clean revert of recent `String::retain` changes

Cleanly revert `String::retain` changes introduced in rust-lang#150067 by also rolling back rust-lang#163624's safety hygiene changes in order to address a performance regression in this function that was reported to us in rust-lang#165988.

While we desire the safety-improving code, that code does not affect the risk of "actual" undefined behavior in the library code. It merely reduces the amount of implementation details we internally rely on and thus whether that code is resilient to changes around it.

r? @hanna-kruppe
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Nov 16, 2026
…-retain, r=hanna-kruppe

Clean revert of recent `String::retain` changes

Cleanly revert `String::retain` changes introduced in rust-lang#150067 by also rolling back rust-lang#163624's safety hygiene changes in order to address a performance regression in this function that was reported to us in rust-lang#165988.

While we desire the safety-improving code, that code does not affect the risk of "actual" undefined behavior in the library code. It merely reduces the amount of implementation details we internally rely on and thus whether that code is resilient to changes around it.

r? @hanna-kruppe
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Nov 16, 2026
…-retain, r=hanna-kruppe

Clean revert of recent `String::retain` changes

Cleanly revert `String::retain` changes introduced in rust-lang#150067 by also rolling back rust-lang#163624's safety hygiene changes in order to address a performance regression in this function that was reported to us in rust-lang#165988.

While we desire the safety-improving code, that code does not affect the risk of "actual" undefined behavior in the library code. It merely reduces the amount of implementation details we internally rely on and thus whether that code is resilient to changes around it.

r? @hanna-kruppe
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Nov 16, 2026
…-retain, r=hanna-kruppe

Clean revert of recent `String::retain` changes

Cleanly revert `String::retain` changes introduced in rust-lang#150067 by also rolling back rust-lang#163624's safety hygiene changes in order to address a performance regression in this function that was reported to us in rust-lang#165988.

While we desire the safety-improving code, that code does not affect the risk of "actual" undefined behavior in the library code. It merely reduces the amount of implementation details we internally rely on and thus whether that code is resilient to changes around it.

r? @hanna-kruppe
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Nov 16, 2026
…-retain, r=hanna-kruppe

Clean revert of recent `String::retain` changes

Cleanly revert `String::retain` changes introduced in rust-lang#150067 by also rolling back rust-lang#163624's safety hygiene changes in order to address a performance regression in this function that was reported to us in rust-lang#165988.

While we desire the safety-improving code, that code does not affect the risk of "actual" undefined behavior in the library code. It merely reduces the amount of implementation details we internally rely on and thus whether that code is resilient to changes around it.

r? @hanna-kruppe
rust-bors Bot pushed a commit that referenced this pull request Nov 16, 2026
…uwer

Rollup of 24 pull requests

Successful merges:

 - #165819 (Avoid redundant scans when extracting stage0 archives)
 - #166011 (Clean revert of recent `String::retain` changes)
 - #159805 (Implemented different with_native_path conversion methods, refactoring fs functions to utilize with_native_path, and move exists to use with_native_path)
 - #162414 (Make min/max and copysign intrinsics generic)
 - #163891 (Do not include context span when source is unavailable to render)
 - #164156 (Improve collapsed suggestions for trait impls tuples)
 - #165900 ([tiny] Tweak wording of missing `core` note)
 - #165978 (Mention `#![doc = include_str!(...)]` trick in intro page)
 - #165979 (Improve index inference diagnostics)
 - #165983 (Update `minifier-rs` dependency version to `0.5.0`)
 - #165999 (Update TPDE submodule)
 - #166005 (add ABI compat checks for new float types)
 - #165406 (Do not suggest `as_deref` for a slice pattern on `Err`)
 - #165792 (prevent optimization for input in ascii benchmarks)
 - #165936 (Enhance documentation for try_clone File implementation)
 - #165938 (`rustc_hir_typeck::upvar`: replace for loop with `.any()`)
 - #165941 (Merge `type_bf16()` with `type_f16b()`)
 - #165942 (windows: use io::const_error in get_access_mode)
 - #165946 (PassWrapper: adapt for latest round of LLVM codegen flag refactor)
 - #165956 (Document wide pointers in core::ptr module)
 - #165987 (Fix panic on non-UTF-8 command-line arguments when `RUST_BACKTRACE` is unset)
 - #165993 (pipe_subprocess test: use libtest harness)
 - #165996 (Fix(docs): Correct discard behavior in datagram peek docs)
 - #165998 (Cleanup borrowck)
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Nov 16, 2026
…-retain, r=hanna-kruppe

Clean revert of recent `String::retain` changes

Cleanly revert `String::retain` changes introduced in rust-lang#150067 by also rolling back rust-lang#163624's safety hygiene changes in order to address a performance regression in this function that was reported to us in rust-lang#165988.

While we desire the safety-improving code, that code does not affect the risk of "actual" undefined behavior in the library code. It merely reduces the amount of implementation details we internally rely on and thus whether that code is resilient to changes around it.

r? @hanna-kruppe
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Nov 16, 2026
…-retain, r=hanna-kruppe

Clean revert of recent `String::retain` changes

Cleanly revert `String::retain` changes introduced in rust-lang#150067 by also rolling back rust-lang#163624's safety hygiene changes in order to address a performance regression in this function that was reported to us in rust-lang#165988.

While we desire the safety-improving code, that code does not affect the risk of "actual" undefined behavior in the library code. It merely reduces the amount of implementation details we internally rely on and thus whether that code is resilient to changes around it.

r? @hanna-kruppe
rust-bors Bot pushed a commit that referenced this pull request Nov 16, 2026
…uwer

Rollup of 21 pull requests

Successful merges:

 - #166011 (Clean revert of recent `String::retain` changes)
 - #165475 (Add a `!type` annotation to a vtable for every supertrait that is a prefix of the vtable)
 - #165881 (fix MSVC calling convention byte counts)
 - #165882 (Add a separate feature gate for EIIs with default impls)
 - #165922 (Prevent inlining of foreign items through glob reexports named `_`)
 - #165979 (Improve index inference diagnostics)
 - #165983 (Update `minifier-rs` dependency version to `0.5.0`)
 - #165613 (Handle trait default values in `mir_for_direct_const`)
 - #165677 (Rewrite relaxed bound policy code)
 - #165861 (cg_llvm: Use an invariant lifetime brand for LLVM attributes)
 - #165990 (gca fixed issue regression tests)
 - #165993 (pipe_subprocess test: use libtest harness)
 - #165998 (Cleanup borrowck)
 - #166005 (add ABI compat checks for new float types)
 - #166009 (Improve `String::insert{,_str}` safety comments)
 - #166021 (Correct and expand E0225 error explanation.)
 - #166029 (rustc-dev-guide subtree update)
 - #166031 (Split packed structs out of `const_struct`)
 - #166032 (Normalize the simd field type before reading its length)
 - #166034 (Three LLVM-type-related cleanups)
 - #166047 (Document AltiVec requirement for powerpc64-unknown-linux-gnuelfv2)
@rust-bors
rust-bors Bot merged commit e29010d into rust-lang:main Nov 16, 2026
14 checks passed
@rustbot rustbot added this to the 1.102.0 milestone Nov 16, 2026
rust-bors Bot pushed a commit that referenced this pull request Nov 16, 2026
Rollup merge of #166011 - workingjubilee:clean-revert-string-retain, r=hanna-kruppe

Clean revert of recent `String::retain` changes

Cleanly revert `String::retain` changes introduced in #150067 by also rolling back #163624's safety hygiene changes in order to address a performance regression in this function that was reported to us in #165988.

While we desire the safety-improving code, that code does not affect the risk of "actual" undefined behavior in the library code. It merely reduces the amount of implementation details we internally rely on and thus whether that code is resilient to changes around it.

r? @hanna-kruppe
@workingjubilee
workingjubilee deleted the clean-revert-string-retain branch November 16, 2026 21:30
sushink70 pushed a commit to sushink70/miri that referenced this pull request Nov 17, 2026
…uwer

Rollup of 21 pull requests

Successful merges:

 - rust-lang/rust#166011 (Clean revert of recent `String::retain` changes)
 - rust-lang/rust#165475 (Add a `!type` annotation to a vtable for every supertrait that is a prefix of the vtable)
 - rust-lang/rust#165881 (fix MSVC calling convention byte counts)
 - rust-lang/rust#165882 (Add a separate feature gate for EIIs with default impls)
 - rust-lang/rust#165922 (Prevent inlining of foreign items through glob reexports named `_`)
 - rust-lang/rust#165979 (Improve index inference diagnostics)
 - rust-lang/rust#165983 (Update `minifier-rs` dependency version to `0.5.0`)
 - rust-lang/rust#165613 (Handle trait default values in `mir_for_direct_const`)
 - rust-lang/rust#165677 (Rewrite relaxed bound policy code)
 - rust-lang/rust#165861 (cg_llvm: Use an invariant lifetime brand for LLVM attributes)
 - rust-lang/rust#165990 (gca fixed issue regression tests)
 - rust-lang/rust#165993 (pipe_subprocess test: use libtest harness)
 - rust-lang/rust#165998 (Cleanup borrowck)
 - rust-lang/rust#166005 (add ABI compat checks for new float types)
 - rust-lang/rust#166009 (Improve `String::insert{,_str}` safety comments)
 - rust-lang/rust#166021 (Correct and expand E0225 error explanation.)
 - rust-lang/rust#166029 (rustc-dev-guide subtree update)
 - rust-lang/rust#166031 (Split packed structs out of `const_struct`)
 - rust-lang/rust#166032 (Normalize the simd field type before reading its length)
 - rust-lang/rust#166034 (Three LLVM-type-related cleanups)
 - rust-lang/rust#166047 (Document AltiVec requirement for powerpc64-unknown-linux-gnuelfv2)
@rustbot

rustbot commented Nov 17, 2026

Copy link
Copy Markdown
Collaborator

beta backport approved as per libs team on Zulip. A backport PR will be authored by the release team at the end of the current development cycle. Backport labels are handled by them.

@rustbot rustbot added the beta-accepted Accepted for backporting to the compiler in the beta channel. label Nov 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-str Area: `str` and `String` beta-accepted Accepted for backporting to the compiler in the beta channel. beta-nominated Nominated for backporting to the compiler in the beta channel. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. 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.

7 participants