Skip to content

Require UTF-8 in Utf8Pattern::StringPattern#156556

Open
qaijuang wants to merge 1 commit into
rust-lang:mainfrom
qaijuang:issue-156491-str-replace-utf8-pattern
Open

Require UTF-8 in Utf8Pattern::StringPattern#156556
qaijuang wants to merge 1 commit into
rust-lang:mainfrom
qaijuang:issue-156491-str-replace-utf8-pattern

Conversation

@qaijuang
Copy link
Copy Markdown
Contributor

@qaijuang qaijuang commented May 13, 2026

Store &str instead, so the UTF-8 invariant is enforced at the API boundary.

Fixes #156491

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels May 13, 2026
@qaijuang qaijuang marked this pull request as ready for review May 13, 2026 20:28
@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label May 13, 2026
@rustbot rustbot removed the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label May 13, 2026
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented May 13, 2026

r? @TaKO8Ki

rustbot has assigned @TaKO8Ki.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: compiler
  • compiler expanded to 73 candidates
  • Random selection from 16 candidates

@qaijuang
Copy link
Copy Markdown
Contributor Author

cc @ChrisDenton

Comment thread tests/ui/str/replace-invalid-utf8-pattern.rs Outdated
Comment thread library/core/src/str/pattern.rs
@qaijuang qaijuang force-pushed the issue-156491-str-replace-utf8-pattern branch from 6c9dd5f to efc95b4 Compare May 14, 2026 06:53
@qaijuang qaijuang requested a review from ChrisDenton May 14, 2026 06:54
Copy link
Copy Markdown
Member

@ChrisDenton ChrisDenton left a comment

Choose a reason for hiding this comment

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

One small thing but otherwise I'm happy to merge this.

View changes since this review

Comment thread library/core/src/str/pattern.rs Outdated
@qaijuang qaijuang force-pushed the issue-156491-str-replace-utf8-pattern branch from efc95b4 to 8909e79 Compare May 15, 2026 01:27
@qaijuang qaijuang requested a review from ChrisDenton May 15, 2026 01:28
@ChrisDenton
Copy link
Copy Markdown
Member

Thanks!

@bors r+ rollup

@rust-bors
Copy link
Copy Markdown
Contributor

rust-bors Bot commented May 15, 2026

📌 Commit 8909e79 has been approved by ChrisDenton

It is now in the queue for this repository.

@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 May 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. 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.

str::replace with a custom Pattern implementation can create a non-UTF-8 String through safe API calls

4 participants