Skip to content
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

DO NOT MERGE: experimental implementation of Entry API RFC #37143

Closed
wants to merge 3 commits into from

Conversation

cristicbz
Copy link
Contributor

RFC: rust-lang/rfcs#1769

  • Implements Entry::key and VacantEntry::key only when Q=K.
  • Updates both BTreeMap and HashMap.
  • The only inference breakage in the rustc codebase was due to Constraint does not match because where clause hides blanket impl #37138 .
  • Uses the single trait no specialisation version with AsBorrowOf.
    • Turns out the lack of an IntoOwned<K> trait ends being annoying requiring a B parameter added to or_insert and or_insert_with.
    • Adding a <B> parameter to or_insert_with is, I think, a breaking change because writing or_insert_with<_> is not valid any more. In reality I imagine this never happens.
    • We may want to go back to the IntoOwned/AsBorrowOf separation.

@rust-highfive
Copy link
Collaborator

r? @sfackler

(rust_highfive has picked a reviewer for you, use r? to override)

@cristicbz
Copy link
Contributor Author

r? @aturon

@brson
Copy link
Contributor

brson commented Oct 13, 2016

Starting crater.

@cristicbz
Copy link
Contributor Author

cristicbz commented Oct 13, 2016

Travis failures are entry doctests for which inference fails now :(. I'll fix them, but shouldn't affect crater run.

@brson
Copy link
Contributor

brson commented Oct 14, 2016

@cristicbz
Copy link
Contributor Author

cristicbz commented Oct 14, 2016

@brson Thanks a lot for doing the crater run!

Here's my analysis of the results. There 9 irreconcilable regressions caused by actual inference failures introduced by widening the allowed argument types of Entry, split about evenly between:

  • Short lived local HashMap with reference key types whose type can no longer be inferred from .entry(some_reference).
  • Usage of Into to convert from &str -> String in calls like string_map.entry(some_str.into()) (this is ambiguous since both the intended conversion and &str -> &str are valid).

Instances of #37164 and #37138 appear once each.

 * B is now type parameter of `Entry`.
 * B is ?Sized in `.entry` methods on maps (previous oversight).
 * Deref coercions are now handled seamlessly by `AsBorrowOf`.
@alexcrichton
Copy link
Member

I'm going to close this in favor of the RFC for now, just trying to clear out the PR queue. I'm fine reopening though once we decide on the RFC!

@cristicbz
Copy link
Contributor Author

@alexcrichton Makes sense, in the meantime I'd love to get more feedback on the RFC though!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants