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

Add drain_filter method to HashMap and HashSet #76458

Merged
merged 4 commits into from
Sep 10, 2020

Conversation

mbrubeck
Copy link
Contributor

@mbrubeck mbrubeck commented Sep 7, 2020

Add HashMap::drain_filter and HashSet::drain_filter, implementing part of rust-lang/rfcs#2140. These new methods are unstable. The tracking issue is #59618.

The added iterators behave the same as BTreeMap::drain_filter and BTreeSet::drain_filter, except their iteration order is arbitrary. The unit tests are adapted from alloc::collections::btree.

This branch rewrites HashSet to be a wrapper around hashbrown::HashSet rather than std::collections::HashMap.
(Both are themselves wrappers around hashbrown::HashMap, so the in-memory representation is the same either way.) This lets std re-use more iterator code from hashbrown. Without this change, we would need to duplicate much more code to implement HashSet::drain_filter.

This branch also updates the hashbrown crate to version 0.9.0. Aside from changes related to the DrainFilter iterators, this version only changes features that are not used in libstd or rustc. And it updates indexmap to version 1.6.0, whose only change is compatibility with hashbrown 0.9.0.

@rust-highfive
Copy link
Collaborator

r? @cramertj

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

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Sep 7, 2020
@Amanieu
Copy link
Member

Amanieu commented Sep 7, 2020

You might want to double-check if the representation change affected the debuginfo providers and tests:

  • Search for HashSet in src/etc/
  • src/test/debuginfo/pretty-std-collections.rs
  • src/test/debuginfo/pretty-std-collections-hash.rs

Otherwise LGTM.

@jyn514 jyn514 added the T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. label Sep 8, 2020
@mbrubeck mbrubeck force-pushed the hash_drain_filter branch 5 times, most recently from 60750d6 to c589c41 Compare September 8, 2020 19:06
@mbrubeck
Copy link
Contributor Author

mbrubeck commented Sep 8, 2020

You might want to double-check if the representation change affected the debuginfo providers and tests.

Thanks for the tip! I updated this branch to fix to debuginfo providers for both gdb and lldb.

@Amanieu
Copy link
Member

Amanieu commented Sep 8, 2020

I think src/etc/natvis/libstd.natvis (Windows debuginfo) also needs to be updated. It is only tested on Windows though, which is why you may not have caught it (and neither has CI).

@mbrubeck
Copy link
Contributor Author

mbrubeck commented Sep 8, 2020

I think src/etc/natvis/libstd.natvis (Windows debuginfo) also needs to be updated.

This is now updated, though I don't have a Windows machine to test it on.

@Amanieu
Copy link
Member

Amanieu commented Sep 8, 2020

@bors r+

@bors
Copy link
Contributor

bors commented Sep 8, 2020

📌 Commit 4bbd823198c127e71a70a6992abbd915f298173a has been approved by Amanieu

@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 Sep 8, 2020
bors added a commit to rust-lang-ci/rust that referenced this pull request Sep 9, 2020
Rollup of 10 pull requests

Successful merges:

 - rust-lang#76162 (Make duration_since documentation more clear)
 - rust-lang#76355 (remove public visibility previously needed for rustfmt)
 - rust-lang#76374 (Improve ayu doc source line number contrast)
 - rust-lang#76379 (rustbuild: Remove `Mode::Codegen`)
 - rust-lang#76389 (Fix HashMap visualizers in Visual Studio (Code))
 - rust-lang#76396 (Fix typo in tracking issue template)
 - rust-lang#76401 (Add help note to unconstrained const parameter)
 - rust-lang#76402 (Update linker-plugin-lto.md to contain up to rust 1.46)
 - rust-lang#76403 (Fix documentation for TyCtxt::all_impls)
 - rust-lang#76498 (Update cargo)

Failed merges:

 - rust-lang#76458 (Add drain_filter method to HashMap and HashSet)

r? `@ghost`
@bors
Copy link
Contributor

bors commented Sep 9, 2020

☔ The latest upstream changes (presumably #76502) made this pull request unmergeable. Please resolve the merge conflicts.

Note that reviewers usually do not review pull requests until merge conflicts are resolved! Once you resolve the conflicts, you should change the labels applied by bors to indicate that your PR is ready for review. Post this as a comment to change the labels:

@rustbot modify labels: +S-waiting-on-review -S-waiting-on-author

@bors bors added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Sep 9, 2020
@mbrubeck
Copy link
Contributor Author

mbrubeck commented Sep 9, 2020

@rustbot modify labels: +S-waiting-on-review -S-waiting-on-author

Rebased to resolve a merge conflict in libstd.natvis.

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Sep 9, 2020
@Amanieu
Copy link
Member

Amanieu commented Sep 9, 2020

@bors r+

@bors
Copy link
Contributor

bors commented Sep 9, 2020

📌 Commit fb1fab5 has been approved by Amanieu

@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 Sep 9, 2020
bors added a commit to rust-lang-ci/rust that referenced this pull request Sep 10, 2020
Rollup of 7 pull requests

Successful merges:

 - rust-lang#74787 (Move `rustllvm` into `compiler/rustc_llvm`)
 - rust-lang#76458 (Add drain_filter method to HashMap and HashSet)
 - rust-lang#76472 (rustbuild: don't set PYTHON_EXECUTABLE and WITH_POLLY cmake vars since they are no longer supported by llvm)
 - rust-lang#76497 (Use intra-doc links in `core::ptr`)
 - rust-lang#76500 (Add -Zgraphviz_dark_mode and monospace font fix)
 - rust-lang#76543 (Document btree's unwrap_unchecked)
 - rust-lang#76556 (Revert rust-lang#76285)

Failed merges:

r? `@ghost`
@bors bors merged commit fa56cf5 into rust-lang:master Sep 10, 2020
@rustbot rustbot added this to the 1.48.0 milestone Sep 10, 2020
artemmukhin added a commit to intellij-rust/intellij-rust that referenced this pull request Oct 6, 2020
artemmukhin added a commit to intellij-rust/intellij-rust that referenced this pull request Oct 14, 2020
bors bot added a commit to intellij-rust/intellij-rust that referenced this pull request Oct 14, 2020
6258: Update HashMap/HashSet pretty-printers to Rust 1.47 r=Undin a=ortem

Fixes #6198

The corresponding PRs in rustc:
rust-lang/rust#76458
rust-lang/rust#70052

Besides these changes from the upstreamed pretty-printers, I've added `GetTypedefedType` (LLDB) and `strip_typedefs` (GDB) calls to resolve key and value types completely. Without these calls, LLDB doesn't show the actual type and so CLion fails to show the content of key/value pairs.

For example,
with `GetTypedefedType`:
```
(lldb) frame variable hm[0]
((i32, alloc::string::String)) hm[0] = { ... }
```

and without:
```
(lldb) frame variable hm[0]
(T) hm[0] = { ... }
```


**Before merge, test on**:
- [x] Linux + Bundled GDB + Rust 1.46
- [x] Linux + Bundled LLDB + Rust 1.46
- [x] Linux + Bundled GDB + Rust 1.47
- [x] Linux + Bundled LLDB + Rust 1.47
- [x] macOS + Bundled LLDB + Rust 1.46
- [x] macOS + Bundled LLDB + Rust 1.47
- [ ] Windows + MinGW/Cygwin GDB + Rust 1.47
- [ ] Windows + MinGW/Cygwin GDB + Rust 1.46
**Does not work on Windows + MSVC LLDB** due to the lack of native Rust support patches

**After merge**
- [ ] Upstream to rustc

Co-authored-by: ortem <[email protected]>
Undin pushed a commit to intellij-rust/intellij-rust that referenced this pull request Oct 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants