Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upslice: allow [T]::contains to accept any Q where T: Borrow<Q> #43020
Conversation
rust-highfive
assigned
aturon
Jul 3, 2017
This comment has been minimized.
This comment has been minimized.
|
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. |
sunshowers
force-pushed the
sunshowers:borrow
branch
from
ef44821
to
f3eceba
Jul 3, 2017
sunshowers
changed the title
slice: allow [T]::contains to accept any Borrow<T>
slice: allow [T]::contains to accept any Q where T: Borrow<Q>
Jul 3, 2017
This comment has been minimized.
This comment has been minimized.
|
BTW, something similar can be done for |
This comment has been minimized.
This comment has been minimized.
|
Hmm, the error in https://travis-ci.org/rust-lang/rust/jobs/249466135 is interesting -- looks like maybe we should implement |
This comment has been minimized.
This comment has been minimized.
|
One option here would be to have something like The other option might be to implement Thoughts? |
This comment has been minimized.
This comment has been minimized.
|
I just bumped into this today. I've got a |
Mark-Simulacrum
reviewed
Jul 3, 2017
| @@ -110,7 +110,7 @@ impl<'a, 'gcx, 'tcx> DefIdForest { | |||
| where I: IntoIterator<Item=DefIdForest> | |||
| { | |||
| let mut ret = DefIdForest::empty(); | |||
| let mut next_ret = SmallVec::new(); | |||
| let mut next_ret: SmallVec<[DefId; 1]> = SmallVec::new(); | |||
This comment has been minimized.
This comment has been minimized.
Mark-Simulacrum
Jul 3, 2017
Member
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.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
vitalyd
commented
Jul 3, 2017
|
@golddranks , a workaround would be to use a |
This comment has been minimized.
This comment has been minimized.
|
@vitalyd Unfortunately that's not an acceptable workaround if a |
This comment has been minimized.
This comment has been minimized.
vitalyd
commented
Jul 3, 2017
|
@golddranks , you mean if you don't have control over the Your workaround using |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
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 |
This comment has been minimized.
This comment has been minimized.
|
Maybe we should do that cargobomb run first before thinking the plan B? |
This comment has been minimized.
This comment has been minimized.
|
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
added
the
S-waiting-on-crater
label
Jul 3, 2017
This comment has been minimized.
This comment has been minimized.
|
@brson Flagging for crater run! |
This comment has been minimized.
This comment has been minimized.
|
Why Borrow and not PartialEq? |
This comment has been minimized.
This comment has been minimized.
|
ping @alexcrichton, @brson, @tomprince, and @frewsxcv for a crater run! |
This comment has been minimized.
This comment has been minimized.
|
Crater does not work any more. @tomprince has cargobomb running against PRs. Maybe he can do it. I will add this to my list. |
This comment has been minimized.
This comment has been minimized.
|
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 |
This comment has been minimized.
This comment has been minimized.
|
|
This comment has been minimized.
This comment has been minimized.
|
Looks like the merge conflict needs to be resolved, then the try run, then cargobomb. |
This comment has been minimized.
This comment has been minimized.
briansmith
commented
Jul 12, 2017
•
|
I agree with @jethrogb that it seems to make more sense to use
|
aidanhs
added
S-waiting-on-author
and removed
S-waiting-on-crater
labels
Jul 13, 2017
This comment has been minimized.
This comment has been minimized.
|
@bors try |
This comment has been minimized.
This comment has been minimized.
|
@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. |
This comment has been minimized.
This comment has been minimized.
|
I'm going to close this out of inactivity, but please feel free to resubmit! |
sunshowers commentedJul 3, 2017
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 :)