Uh oh!
There was an error while loading. Please reload this page.
slice: allow [T]::contains to accept any Q where T: Borrow<Q> - #43020
slice: allow [T]::contains to accept any Q where T: Borrow<Q>#43020sunshowers wants to merge 1 commit into
Conversation
rust-highfive
commented
Jul 3, 2017
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @aturon (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. |
This is most useful to allow matching string literals against a `[String]`, or bytestring literals against a `[Vec<u8>]`. Since `Vec<T>` derefs to `[T]`, this also applies to `Vec<String>` and `Vec<Vec<u8>>`.
sunshowers
commented
Jul 3, 2017
BTW, something similar can be done for |
sunshowers
commented
Jul 3, 2017
Hmm, the error in https://travis-ci.org/rust-lang/rust/jobs/249466135 is interesting -- looks like maybe we should implement |
sunshowers
commented
Jul 3, 2017
One option here would be to have something like The other option might be to implement Thoughts? |
golddranks
commented
Jul 3, 2017
I just bumped into this today. I've got a |
| { | ||
| let mut ret = DefIdForest::empty(); | ||
| let mut next_ret = SmallVec::new(); | ||
| let mut next_ret: SmallVec<[DefId; 1]> = SmallVec::new(); |
There was a problem hiding this comment.
This feels like an unrelated change? Unless inference is failing, as I suspect it is, in which case I'm not sure we'd be able to land this -- too much breakage.
There was a problem hiding this comment.
Yeah, inference was failing in this case.
vitalyd
commented
Jul 3, 2017
@golddranks , a workaround would be to use a |
@vitalyd Unfortunately that's not an acceptable workaround if a |
vitalyd
commented
Jul 3, 2017
@golddranks , you mean if you don't have control over the Your workaround using |
aturon
commented
Jul 3, 2017
Note, this PR is closely related to:
The latter is a PR doing something similar for |
sunshowers
commented
Jul 3, 2017
Yeah the inference breaking is unfortunate :( seems like this could have been fixed before 1.0, but it's too late now. @aturon Do you think it's worth adding |
golddranks
commented
Jul 3, 2017
Maybe we should do that cargobomb run first before thinking the plan B? |
sunshowers
commented
Jul 3, 2017
I'm fine with that. Note that inference wasn't the only thing failing -- https://travis-ci.org/rust-lang/rust/jobs/249466135 has an example of code that was accepted earlier (extra &) now failing. |
aturon
commented
Jul 3, 2017
@brson Flagging for crater run! |
jethrogb
commented
Jul 4, 2017
Why Borrow and not PartialEq? |
carols10cents
commented
Jul 10, 2017
ping @alexcrichton, @brson, @tomprince, and @frewsxcv for a crater run! |
brson
commented
Jul 11, 2017
Crater does not work any more. @tomprince has cargobomb running against PRs. Maybe he can do it. I will add this to my list. |
Mark-Simulacrum
commented
Jul 11, 2017
Looking at the PR's travis log, this failed cargotest -- clap had inference failures. So I worry that we shouldn't do this. However, in order to run cargobomb, we'll need to get the artifacts; this may not work due to the cargotest failure but I guess we can try: @bors try |
bors
commented
Jul 11, 2017
🔒 Merge conflict |
brson
commented
Jul 11, 2017
Looks like the merge conflict needs to be resolved, then the try run, then cargobomb. |
I agree with @jethrogb that it seems to make more sense to use |
brson
commented
Jul 14, 2017
@bors try |
aidanhs
commented
Jul 20, 2017
@Sid0 could you take a look at rebasing? In order to get artifacts, I believe we'll need to do alter the CI for this job to not build rustbook - I don't see how we'll get to the deploy stage otherwise. I don't know how to achieve that off the top of my head, so I'll look into it. |
alexcrichton
commented
Jul 27, 2017
I'm going to close this out of inactivity, but please feel free to resubmit! |
This allows `contains` to be used on slices to search for elements that satisfy a partial equality with the slice item type, rather than an identity. This closesrust-lang#42671. Note that string literals need to be referenced in this implementation due to `str` not implementing `Sized`. It’s likely this will have to go through a Crater run to test for breakage (see rust-lang#43020).
Generalise slice::contains over PartialEq This allows `contains` to be used on slices to search for elements that satisfy a partial equality with the slice item type, rather than an identity. This closes#42671. Note that string literals need to be referenced in this implementation due to `str` not implementing `Sized`. It’s likely this will have to go through a Crater run to test for breakage (see #43020).
This is most useful to allow matching string literals against a
[String], or bytestring literals against a[Vec<u8>].Since
Vec<T>derefs to[T], this also applies toVec<String>andVec<Vec<u8>>.This implements https://internals.rust-lang.org/t/vec-contains-should-accept-anything-that-t-implements-borrow-for/5455 -- I'm really not sure about the stability guarantees required here, so some guidance would be really appreciated. Thanks :)