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

Already on GitHub? Sign in to your account

Implement PartialEq between &str and OsString #51178

Merged
merged 3 commits into from Jun 30, 2018

Conversation

Projects
None yet
@GabrielMajeri
Contributor

GabrielMajeri commented May 29, 2018

This fixes #49854.

It allows equality comparison between OsString values and str references, such as os_string == "something".

@rust-highfive

This comment has been minimized.

Show comment
Hide comment
@rust-highfive

rust-highfive May 29, 2018

Collaborator

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @bluss (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see the contribution instructions for more information.

Collaborator

rust-highfive commented May 29, 2018

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @bluss (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see the contribution instructions for more information.

@rust-highfive

This comment has been minimized.

Show comment
Hide comment
@rust-highfive

rust-highfive May 29, 2018

Collaborator

The job x86_64-gnu-llvm-3.9 of your PR failed on Travis (raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log.
travis_time:start:tidy
tidy check
[00:04:57] * 547 error codes
[00:04:57] * highest error code: E0911
[00:04:58] tidy error: /checkout/src/libstd/ffi/os_str.rs:420: mismatches to previous in: ["since"]
[00:04:58] tidy error: /checkout/src/libstd/ffi/os_str.rs:434: mismatches to previous in: ["since"]
[00:04:58] some tidy checks failed
[00:04:58] 
[00:04:58] 
[00:04:58] command did not execute successfully: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-tools-bin/tidy" "/checkout/src" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0/bin/cargo" "--no-vendor" "--quiet"
[00:04:58] 
[00:04:58] 
[00:04:58] failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test src/tools/tidy
[00:04:58] Build completed unsuccessfully in 0:01:52
[00:04:58] Build completed unsuccessfully in 0:01:52
[00:04:58] Makefile:79: recipe for target 'tidy' failed
[00:04:58] make: *** [tidy] Error 1

The command "stamp sh -x -c "$RUN_SCRIPT"" exited with 2.
travis_time:start:03bf8b10
$ date && (curl -fs --head https://google.com | grep ^Date: | sed 's/Date: //g' || true)

I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact @TimNN. (Feature Requests)

Collaborator

rust-highfive commented May 29, 2018

The job x86_64-gnu-llvm-3.9 of your PR failed on Travis (raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log.
travis_time:start:tidy
tidy check
[00:04:57] * 547 error codes
[00:04:57] * highest error code: E0911
[00:04:58] tidy error: /checkout/src/libstd/ffi/os_str.rs:420: mismatches to previous in: ["since"]
[00:04:58] tidy error: /checkout/src/libstd/ffi/os_str.rs:434: mismatches to previous in: ["since"]
[00:04:58] some tidy checks failed
[00:04:58] 
[00:04:58] 
[00:04:58] command did not execute successfully: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-tools-bin/tidy" "/checkout/src" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0/bin/cargo" "--no-vendor" "--quiet"
[00:04:58] 
[00:04:58] 
[00:04:58] failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test src/tools/tidy
[00:04:58] Build completed unsuccessfully in 0:01:52
[00:04:58] Build completed unsuccessfully in 0:01:52
[00:04:58] Makefile:79: recipe for target 'tidy' failed
[00:04:58] make: *** [tidy] Error 1

The command "stamp sh -x -c "$RUN_SCRIPT"" exited with 2.
travis_time:start:03bf8b10
$ date && (curl -fs --head https://google.com | grep ^Date: | sed 's/Date: //g' || true)

I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact @TimNN. (Feature Requests)

@GabrielMajeri

This comment has been minimized.

Show comment
Hide comment
@GabrielMajeri

GabrielMajeri May 29, 2018

Contributor

Not sure which stability attributes would be right for this change.

Contributor

GabrielMajeri commented May 29, 2018

Not sure which stability attributes would be right for this change.

@frewsxcv frewsxcv added the T-libs label May 30, 2018

@clarcharr

This comment has been minimized.

Show comment
Hide comment
@clarcharr

clarcharr May 30, 2018

Contributor

@GabrielMajeri what you have is fine, although you should change feature = "rust1" to something else, like feature = "os_str_str_ref_eq" or something like that

Contributor

clarcharr commented May 30, 2018

@GabrielMajeri what you have is fine, although you should change feature = "rust1" to something else, like feature = "os_str_str_ref_eq" or something like that

@pietroalbini

This comment has been minimized.

Show comment
Hide comment
@pietroalbini

pietroalbini Jun 4, 2018

Member

Ping from triage @bluss! This PR needs your review.

Member

pietroalbini commented Jun 4, 2018

Ping from triage @bluss! This PR needs your review.

@estebank

This comment has been minimized.

Show comment
Hide comment
@estebank

estebank Jun 4, 2018

Contributor

Can you add a run-pass test for the feature?

Contributor

estebank commented Jun 4, 2018

Can you add a run-pass test for the feature?

@estebank

This comment has been minimized.

Show comment
Hide comment
@estebank

estebank Jun 5, 2018

Contributor

@rust-lang/lang should this be instastable on 1.28? Other than that lgtm.

Contributor

estebank commented Jun 5, 2018

@rust-lang/lang should this be instastable on 1.28? Other than that lgtm.

@nikomatsakis

This comment has been minimized.

Show comment
Hide comment
@nikomatsakis

nikomatsakis Jun 5, 2018

Contributor

That's really a @rust-lang/libs decision, I think.

Contributor

nikomatsakis commented Jun 5, 2018

That's really a @rust-lang/libs decision, I think.

@nikomatsakis

This comment has been minimized.

Show comment
Hide comment
@nikomatsakis

nikomatsakis Jun 5, 2018

Contributor

Was it formally decided elsewhere to add these impls? I don't see much discussion on #49854

Contributor

nikomatsakis commented Jun 5, 2018

Was it formally decided elsewhere to add these impls? I don't see much discussion on #49854

@nikomatsakis

This comment has been minimized.

Show comment
Hide comment
@nikomatsakis

nikomatsakis Jun 5, 2018

Contributor

I'm nominated for someone on @rust-lang/libs to render a decision of some kind.

Contributor

nikomatsakis commented Jun 5, 2018

I'm nominated for someone on @rust-lang/libs to render a decision of some kind.

@dtolnay

This comment has been minimized.

Show comment
Hide comment
@dtolnay

dtolnay Jun 5, 2018

Member

We have all of the following:

// & <-> Owned are comparable
impl<'a> PartialEq<&'a str> for String
impl<'a> PartialEq<String> for &'a str

// utf8 <-> OS are comparable
impl PartialEq<str> for OsString
impl PartialEq<OsString> for str

So I believe it makes sense to provide these as well.

impl<'a> PartialEq<&'a str> for OsString
impl<'a> PartialEq<OsString> for &'a str

@rfcbot fcp merge

Member

dtolnay commented Jun 5, 2018

We have all of the following:

// & <-> Owned are comparable
impl<'a> PartialEq<&'a str> for String
impl<'a> PartialEq<String> for &'a str

// utf8 <-> OS are comparable
impl PartialEq<str> for OsString
impl PartialEq<OsString> for str

So I believe it makes sense to provide these as well.

impl<'a> PartialEq<&'a str> for OsString
impl<'a> PartialEq<OsString> for &'a str

@rfcbot fcp merge

@rfcbot

This comment has been minimized.

Show comment
Hide comment
@rfcbot

rfcbot Jun 5, 2018

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

No concerns currently listed.

Once a majority of reviewers approve (and none object), 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 commented Jun 5, 2018

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

No concerns currently listed.

Once a majority of reviewers approve (and none object), 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 comment has been minimized.

Show comment
Hide comment
@rfcbot

rfcbot Jun 19, 2018

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

rfcbot commented Jun 19, 2018

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

@rfcbot

This comment has been minimized.

Show comment
Hide comment
@rfcbot

rfcbot Jun 29, 2018

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

rfcbot commented Jun 29, 2018

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

@SimonSapin

This comment has been minimized.

Show comment
Hide comment
@SimonSapin

SimonSapin Jun 29, 2018

Contributor

@bors r+

Contributor

SimonSapin commented Jun 29, 2018

@bors r+

@bors

This comment has been minimized.

Show comment
Hide comment
@bors

bors Jun 29, 2018

Contributor

📌 Commit 1e85cb3 has been approved by SimonSapin

Contributor

bors commented Jun 29, 2018

📌 Commit 1e85cb3 has been approved by SimonSapin

@bors

This comment has been minimized.

Show comment
Hide comment
@bors

bors Jun 29, 2018

Contributor

🔒 Merge conflict

This pull request and the master branch diverged in a way that cannot be automatically merged. Please rebase on top of the latest master branch, and let the reviewer approve again.

How do I rebase?

Assuming self is your fork and upstream is this repository, you can resolve the conflict following these steps:

  1. git checkout os-str-compare (switch to your branch)
  2. git fetch upstream master (retrieve the latest master)
  3. git rebase upstream/master -p (rebase on top of it)
  4. Follow the on-screen instruction to resolve conflicts (check git status if you got lost).
  5. git push self os-str-compare --force-with-lease (update this PR)

You may also read Git Rebasing to Resolve Conflicts by Drew Blessing for a short tutorial.

Please avoid the "Resolve conflicts" button on GitHub. It uses git merge instead of git rebase which makes the PR commit history more difficult to read.

Sometimes step 4 will complete without asking for resolution. This is usually due to difference between how Cargo.lock conflict is handled during merge and rebase. This is normal, and you should still perform step 5 to update this PR.

Error message
CONFLICT (file/directory): There is a directory with name src/libbacktrace in heads/homu-tmp. Adding src/libbacktrace as src/libbacktrace~HEAD
Automatic merge failed; fix conflicts and then commit the result.

Contributor

bors commented Jun 29, 2018

🔒 Merge conflict

This pull request and the master branch diverged in a way that cannot be automatically merged. Please rebase on top of the latest master branch, and let the reviewer approve again.

How do I rebase?

Assuming self is your fork and upstream is this repository, you can resolve the conflict following these steps:

  1. git checkout os-str-compare (switch to your branch)
  2. git fetch upstream master (retrieve the latest master)
  3. git rebase upstream/master -p (rebase on top of it)
  4. Follow the on-screen instruction to resolve conflicts (check git status if you got lost).
  5. git push self os-str-compare --force-with-lease (update this PR)

You may also read Git Rebasing to Resolve Conflicts by Drew Blessing for a short tutorial.

Please avoid the "Resolve conflicts" button on GitHub. It uses git merge instead of git rebase which makes the PR commit history more difficult to read.

Sometimes step 4 will complete without asking for resolution. This is usually due to difference between how Cargo.lock conflict is handled during merge and rebase. This is normal, and you should still perform step 5 to update this PR.

Error message
CONFLICT (file/directory): There is a directory with name src/libbacktrace in heads/homu-tmp. Adding src/libbacktrace as src/libbacktrace~HEAD
Automatic merge failed; fix conflicts and then commit the result.

GabrielMajeri added some commits May 29, 2018

Implement PartialEq between &str and OsString
Allows for example `os_string == "something"`
@estebank

This comment has been minimized.

Show comment
Hide comment
@estebank

estebank Jun 29, 2018

Contributor

@bors r=SimonSapin

Contributor

estebank commented Jun 29, 2018

@bors r=SimonSapin

@bors

This comment has been minimized.

Show comment
Hide comment
@bors

bors Jun 29, 2018

Contributor

📌 Commit fbd3c92 has been approved by SimonSapin

Contributor

bors commented Jun 29, 2018

📌 Commit fbd3c92 has been approved by SimonSapin

Mark-Simulacrum added a commit to Mark-Simulacrum/rust that referenced this pull request Jun 30, 2018

Rollup merge of #51178 - GabrielMajeri:os-str-compare, r=SimonSapin
Implement PartialEq between &str and OsString

This fixes #49854.

It allows equality comparison between `OsString` values and `str` references, such as `os_string == "something"`.

bors added a commit that referenced this pull request Jun 30, 2018

Auto merge of #51930 - Mark-Simulacrum:rollup, r=Mark-Simulacrum
Rollup of 11 pull requests

Successful merges:

 - #51178 (Implement PartialEq between &str and OsString)
 - #51762 (hygiene: Implement transparent marks and use them for call-site hygiene in proc-macros)
 - #51828 (Do not allow LLVM to increase a TLS's alignment on macOS.)
 - #51853 (Fix some doc links)
 - #51862 (Point to lifetime spans on lifetime errors)
 - #51864 (Update liblibc)
 - #51867 (Require type is sized in wfcheck.check_item_type for externed DSTs, c…)
 - #51883 (Suggest correct comparison against negative literal)
 - #51890 (Fix inconsequential typo in GlobalAlloc doc example)
 - #51920 (use literal span for concrete type suggestion)
 - #51921 (improve the error message when `#[panic_implementation]` is missing)

Failed merges:

r? @ghost
@bors

This comment has been minimized.

Show comment
Hide comment
@bors

bors Jun 30, 2018

Contributor

⌛️ Testing commit fbd3c92 with merge 87ecf54...

Contributor

bors commented Jun 30, 2018

⌛️ Testing commit fbd3c92 with merge 87ecf54...

bors added a commit that referenced this pull request Jun 30, 2018

Auto merge of #51178 - GabrielMajeri:os-str-compare, r=SimonSapin
Implement PartialEq between &str and OsString

This fixes #49854.

It allows equality comparison between `OsString` values and `str` references, such as `os_string == "something"`.
@bors

This comment has been minimized.

Show comment
Hide comment
@bors

bors Jun 30, 2018

Contributor

☀️ Test successful - status-appveyor, status-travis
Approved by: SimonSapin
Pushing 87ecf54 to master...

Contributor

bors commented Jun 30, 2018

☀️ Test successful - status-appveyor, status-travis
Approved by: SimonSapin
Pushing 87ecf54 to master...

@bors bors merged commit fbd3c92 into rust-lang:master Jun 30, 2018

2 checks passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
homu Test successful
Details

@GabrielMajeri GabrielMajeri deleted the GabrielMajeri:os-str-compare branch Jun 30, 2018

netbsd-srcmastr pushed a commit to NetBSD/pkgsrc that referenced this pull request Sep 14, 2018

rust: Update to 1.29.0.
Version 1.29.0 (2018-09-13)
==========================

Compiler
--------
- [Bumped minimum LLVM version to 5.0.][51899]
- [Added `powerpc64le-unknown-linux-musl` target.][51619]
- [Added `aarch64-unknown-hermit` and `x86_64-unknown-hermit` targets.][52861]

Libraries
---------
- [`Once::call_once` now no longer requires `Once` to be `'static`.][52239]
- [`BuildHasherDefault` now implements `PartialEq` and `Eq`.][52402]
- [`Box<CStr>`, `Box<OsStr>`, and `Box<Path>` now implement `Clone`.][51912]
- [Implemented `PartialEq<&str>` for `OsString` and `PartialEq<OsString>`
  for `&str`.][51178]
- [`Cell<T>` now allows `T` to be unsized.][50494]
- [`SocketAddr` is now stable on Redox.][52656]

Stabilized APIs
---------------
- [`Arc::downcast`]
- [`Iterator::flatten`]
- [`Rc::downcast`]

Cargo
-----
- [Cargo can silently fix some bad lockfiles ][cargo/5831] You can use
  `--locked` to disable this behaviour.
- [`cargo-install` will now allow you to cross compile an install
  using `--target`][cargo/5614]
- [Added the `cargo-fix` subcommand to automatically move project code from
  2015 edition to 2018.][cargo/5723]

Misc
----
- [`rustdoc` now has the `--cap-lints` option which demotes all lints above
  the specified level to that level.][52354] For example `--cap-lints warn`
  will demote `deny` and `forbid` lints to `warn`.
- [`rustc` and `rustdoc` will now have the exit code of `1` if compilation
  fails, and `101` if there is a panic.][52197]
- [A preview of clippy has been made available through rustup.][51122]
  You can install the preview with `rustup component add clippy-preview`

Compatibility Notes
-------------------
- [`str::{slice_unchecked, slice_unchecked_mut}` are now deprecated.][51807]
  Use `str::get_unchecked(begin..end)` instead.
- [`std::env::home_dir` is now deprecated for its unintuitive behaviour.][51656]
  Consider using the `home_dir` function from
  https://crates.io/crates/dirs instead.
- [`rustc` will no longer silently ignore invalid data in target spec.][52330]

[52861]: rust-lang/rust#52861
[52656]: rust-lang/rust#52656
[52239]: rust-lang/rust#52239
[52330]: rust-lang/rust#52330
[52354]: rust-lang/rust#52354
[52402]: rust-lang/rust#52402
[52103]: rust-lang/rust#52103
[52197]: rust-lang/rust#52197
[51807]: rust-lang/rust#51807
[51899]: rust-lang/rust#51899
[51912]: rust-lang/rust#51912
[51511]: rust-lang/rust#51511
[51619]: rust-lang/rust#51619
[51656]: rust-lang/rust#51656
[51178]: rust-lang/rust#51178
[51122]: rust-lang/rust#51122
[50494]: rust-lang/rust#50494
[cargo/5614]: rust-lang/cargo#5614
[cargo/5723]: rust-lang/cargo#5723
[cargo/5831]: rust-lang/cargo#5831
[`Arc::downcast`]: https://doc.rust-lang.org/std/sync/struct.Arc.html#method.downcast
[`Iterator::flatten`]: https://doc.rust-lang.org/std/iter/trait.Iterator.html#method.flatten
[`Rc::downcast`]: https://doc.rust-lang.org/std/rc/struct.Rc.html#method.downcast
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment