Allow comparisons between CStr, CString, and Cow<CStr>. by bjoernager · Pull Request #137268 · rust-lang/rust (original) (raw)

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 andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Conversation18 Commits1 Checks0 Files changed

Conversation

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

[ Show hidden characters]({{ revealButtonHref }})

bjoernager

Closes: #137265

This PR adds the trait implementations proposed in the ACP under the c_string_eq_c_str feature gate:

// core::ffi

impl PartialEq<&Self> for CStr;

impl PartialEq for CStr;

impl PartialEq<Cow<'_, Self>> for CStr;

// alloc::ffi

impl PartialEq for CString;

impl PartialEq<&CStr> for CString;

impl PartialEq<Cow<'_, CStr>> for CString;

// alloc::borrow

impl PartialEq for Cow<'_, CStr>;

impl PartialEq<&CStr> for Cow<'_, CStr>;

impl PartialEq for Cow<'_, CStr>;

As I understand it, stable traits cannot be unstably implemented for stable types, and we would thereby be forced to skip the FCP and directly stabilise these implementations (as is done in this PR).

(@joshtriplett mentioned that Crater may have to be run).

@rustbot

r? @Amanieu

rustbot has assigned @Amanieu.
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

@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

Feb 19, 2025

@bjoernager

@rustbot label +T-libs-api -T-libs

r? libs-api

@rustbot rustbot added T-libs-api

Relevant to the library API team, which will review and decide on the PR/issue.

and removed T-libs

Relevant to the library team, which will review and decide on the PR/issue.

labels

Feb 19, 2025

@rustbot

This comment has been minimized.

@bjoernager bjoernager changed the titleImplement PartialEq<{&Self, CString}> for CStr and PartialEq<{CStr, &CStr}> for CString. Allow comparisons between CStr, CString, and Cow<CStr>.

Feb 19, 2025

@bjoernager

…ent 'PartialEq<{CStr, &CStr, Cow}>' for 'CString'; Implement 'PartialEq<{CStr, &CStr, CString}>' for 'Cow';

@bjoernager

@jieyouxu

@Amanieu

bors added a commit to rust-lang-ci/rust that referenced this pull request

Apr 30, 2025

@bors

Allow comparisons between CStr, CString, and Cow<CStr>.

Closes: rust-lang#137265

This PR adds the trait implementations proposed in the ACP under the c_string_eq_c_str feature gate:

// core::ffi

impl PartialEq<&Self> for CStr;

impl PartialEq<CString> for CStr;

impl PartialEq<Cow<'_, Self>> for CStr;

// alloc::ffi

impl PartialEq<CStr> for CString;

impl PartialEq<&CStr> for CString;

impl PartialEq<Cow<'_, CStr>> for CString;

// alloc::borrow

impl PartialEq<CStr> for Cow<'_, CStr>;

impl PartialEq<&CStr> for Cow<'_, CStr>;

impl PartialEq<CString> for Cow<'_, CStr>;

As I understand it, stable traits cannot be unstably implemented for stable types, and we would thereby be forced to skip the FCP and directly stabilise these implementations (as is done in this PR).

(@joshtriplett mentioned that Crater may have to be run).

@bors

@bors

☀️ Try build successful - checks-actions
Build commit: 1f308f1 (1f308f12738d8cc40bb23bf0c8114b37c164bb49)

@Amanieu

@craterbot

@craterbot

🚧 Experiment pr-137268 is now running

ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more

@craterbot

@Amanieu

@rfcbot

Team member @Amanieu has proposed to merge this. The next step is review by the rest of the tagged team members:

No concerns currently listed.

Once a majority of reviewers approve (and at most 2 approvals are outstanding), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up!

See this document for info about what commands tagged team members can give me.

@rfcbot

🔔 This is now entering its final comment period, as per the review above. 🔔

@rfcbot

The final comment period, with a disposition to merge, as per the review above, is now complete.

As the automated representative of the governance process, I would like to thank the author for their work and everyone else who contributed.

This will be merged soon.

@Amanieu

@bors

📌 Commit 817b093 has been approved by Amanieu

It is now in the queue for this repository.

@bors bors 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

Jun 24, 2025

bors added a commit that referenced this pull request

Jun 24, 2025

@bors

Rollup of 7 pull requests

Successful merges:

Failed merges:

r? @ghost @rustbot modify labels: rollup

rust-timer added a commit that referenced this pull request

Jun 24, 2025

@rust-timer

Rollup merge of #137268 - bjoernager:c-string-eq-c-str, r=Amanieu

Allow comparisons between CStr, CString, and Cow<CStr>.

Closes: #137265

This PR adds the trait implementations proposed in the ACP under the c_string_eq_c_str feature gate:

// core::ffi

impl PartialEq<&Self> for CStr;

impl PartialEq<CString> for CStr;

impl PartialEq<Cow<'_, Self>> for CStr;

// alloc::ffi

impl PartialEq<CStr> for CString;

impl PartialEq<&CStr> for CString;

impl PartialEq<Cow<'_, CStr>> for CString;

// alloc::borrow

impl PartialEq<CStr> for Cow<'_, CStr>;

impl PartialEq<&CStr> for Cow<'_, CStr>;

impl PartialEq<CString> for Cow<'_, CStr>;

As I understand it, stable traits cannot be unstably implemented for stable types, and we would thereby be forced to skip the FCP and directly stabilise these implementations (as is done in this PR).

(@joshtriplett mentioned that Crater may have to be run).

workingjubilee added a commit to workingjubilee/rustc that referenced this pull request

Jun 28, 2025

@workingjubilee

…tr, r=Amanieu"

This reverts commit 30550c0, reversing changes made to 36b2163.

rust-bors bot added a commit that referenced this pull request

Jun 29, 2025

@rust-bors

Revert "Rollup merge of #137268 - bjoernager:c-string-eq-c-str, r=Amanieu"

This reverts commit 30550c0, reversing changes made to 36b2163.

This is an experiment for purposes of retrying the relevant crater run.

r? @ghost

Labels

disposition-merge

This issue / PR is in PFCP or FCP with a disposition to merge it.

finished-final-comment-period

The final comment period is finished for this PR / Issue.

S-waiting-on-bors

Status: Waiting on bors to run and complete tests. Bors will change the label on completion.

T-libs-api

Relevant to the library API team, which will review and decide on the PR/issue.