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

WIP Add Set entry API #120077

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

SUPERCILEX
Copy link
Contributor

@SUPERCILEX SUPERCILEX commented Jan 18, 2024

@rustbot
Copy link
Collaborator

rustbot commented Jan 18, 2024

r? @thomcc

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

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Jan 18, 2024
T: Hash,
S: BuildHasher,
{
todo!()
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cuviper @the8472 self.bash.insert_entry() needs to be public in hashbrown. Is it ok if I do that for rustc-internal-api?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See what @Amanieu thinks as the hashbrown maintainer.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer that is be added as a public API in hashbrown too.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What would be the difference between insert and insert_entry? It kind of seems to me like those are the same API? Please correct me if I'm wrong, but otherwise I'd propose deprecating insert and making insert_entry public in hashbrown and then just having insert_entry -> OccupiedEntry in the stdlib.

https://doc.rust-lang.org/std/collections/hash_map/struct.VacantEntry.html#method.insert
The hashmap needs both insert and insert_entry because one returns a reference to the value while the other to the entry. But for hashset there is no value, so we don't need insert at all.

Thoughts?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Amanieu thoughts on the API changes I proposed?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we could just change insert to always return an OccupiedEntry and remove insert_entry.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't that be a breaking change for hashbrown? But yeah it'd be ideal.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's fine to make breaking changes to hashbrown, it just means that a major version bump is needed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good, done! rust-lang/hashbrown#495

@rust-log-analyzer

This comment has been minimized.

@cuviper
Copy link
Member

cuviper commented Jan 18, 2024

I assume the PR title is wrong here? This is adding HashSet::entry and friends...

@SUPERCILEX SUPERCILEX changed the title Add missing reserve assumes for Vec and String WIP Add Set entry API Jan 18, 2024
@SUPERCILEX
Copy link
Contributor Author

I assume the PR title is wrong here? This is adding HashSet::entry and friends...

Oops, thanks. Rebase error.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

Signed-off-by: Alex Saveau <saveau.alexandre@gmail.com>
@rust-log-analyzer
Copy link
Collaborator

The job mingw-check failed! Check out the build log: (web) (plain)

Click to see the possible cause of the failure (guessed by this bot)
GITHUB_ACTION=__run_7
GITHUB_ACTIONS=true
GITHUB_ACTION_REF=
GITHUB_ACTION_REPOSITORY=
GITHUB_ACTOR=SUPERCILEX
GITHUB_API_URL=https://api.github.com
GITHUB_BASE_REF=master
GITHUB_ENV=/home/runner/work/_temp/_runner_file_commands/set_env_571505aa-7453-4f35-97ba-6720d8a2a77e
GITHUB_EVENT_NAME=pull_request
GITHUB_EVENT_NAME=pull_request
GITHUB_EVENT_PATH=/home/runner/work/_temp/_github_workflow/event.json
GITHUB_GRAPHQL_URL=https://api.github.com/graphql
GITHUB_HEAD_REF=set-entry
GITHUB_JOB=pr
GITHUB_PATH=/home/runner/work/_temp/_runner_file_commands/add_path_571505aa-7453-4f35-97ba-6720d8a2a77e
GITHUB_REF=refs/pull/120077/merge
GITHUB_REF_NAME=120077/merge
GITHUB_REF_PROTECTED=false
---
GITHUB_SERVER_URL=https://github.com
GITHUB_SHA=c3240d663e2cacd1891ec4b0a2f55391c3fd2932
GITHUB_STATE=/home/runner/work/_temp/_runner_file_commands/save_state_571505aa-7453-4f35-97ba-6720d8a2a77e
GITHUB_STEP_SUMMARY=/home/runner/work/_temp/_runner_file_commands/step_summary_571505aa-7453-4f35-97ba-6720d8a2a77e
GITHUB_TRIGGERING_ACTOR=SUPERCILEX
GITHUB_WORKFLOW_REF=rust-lang/rust/.github/workflows/ci.yml@refs/pull/120077/merge
GITHUB_WORKFLOW_SHA=c3240d663e2cacd1891ec4b0a2f55391c3fd2932
GITHUB_WORKSPACE=/home/runner/work/rust/rust
GOROOT_1_19_X64=/opt/hostedtoolcache/go/1.19.13/x64
---
   Doc-tests std

running 1173 tests
........................iii.............................i...............................   88/1173
........................................................F.F.............................  176/1173
........................................................................................  352/1173
........................................................................................  440/1173
..................................ii....................................................  528/1173
................................i....i..................................................  616/1173
---
.........i...................

failures:

---- library/std/src/collections/hash/set.rs - collections::hash::set::Entry (line 1863) stdout ----
error: doctest failed, to rerun pass `-p std --doc`
Test executable failed (exit status: 101).
stderr:
thread 'main' panicked at /checkout/library/std/src/collections/hash/set.rs:2289:9:
not yet implemented
stack backtrace:
---
   7:     0x55628153a309 - std::panicking::begin_panic_handler::{{closure}}::h050fd3a042aa14d7
   8:     0x556281538fc6 - std::sys_common::backtrace::__rust_end_short_backtrace::ha34c79bca2d7112e
   9:     0x55628153a054 - rust_begin_unwind
  10:     0x5562814fed05 - core::panicking::panic_fmt::h500bb33cd24b6cba
  11:     0x5562814fedc3 - core::panicking::panic::hc53f706a99f04a4d
  12:     0x5562815007d0 - std::collections::hash::set::VacantEntry<T,S>::insert_entry::h44618a0d4a0e8413
  13:     0x5562815004e6 - std::collections::hash::set::Entry<T,S>::insert::h6685cad8afc0ab0a
  14:     0x5562815155b7 - rust_out::main::_doctest_main_library_std_src_collections_hash_set_rs_1863_0::h36c7b348bd070a89
  15:     0x556281515366 - rust_out::main::h71185a25be64b52e
  16:     0x556281503443 - core::ops::function::FnOnce::call_once::h7af256b740eb5453
  18:     0x5562815014e9 - std::rt::lang_start::{{closure}}::hf92ba4f93a08128a
  19:     0x556281533a06 - std::rt::lang_start_internal::hbeed09ea1fc92c20
  20:     0x5562815014c7 - std::rt::lang_start::h2b98a589fffc6873
  21:     0x556281515855 - main
---
   7:     0x561363f05cf9 - std::panicking::begin_panic_handler::{{closure}}::h050fd3a042aa14d7
   8:     0x561363f049b6 - std::sys_common::backtrace::__rust_end_short_backtrace::ha34c79bca2d7112e
   9:     0x561363f05a44 - rust_begin_unwind
  10:     0x561363eda8f5 - core::panicking::panic_fmt::h500bb33cd24b6cba
  11:     0x561363eda9b3 - core::panicking::panic::hc53f706a99f04a4d
  12:     0x561363edb720 - std::collections::hash::set::VacantEntry<T,S>::insert_entry::h44618a0d4a0e8413
  13:     0x561363edb5c6 - std::collections::hash::set::Entry<T,S>::insert::h6685cad8afc0ab0a
  14:     0x561363ee1d5d - rust_out::main::_doctest_main_library_std_src_collections_hash_set_rs_2036_0::h183bbc339dac315e
  15:     0x561363ee1ce6 - rust_out::main::h71185a25be64b52e
  17:     0x561363edb4f6 - std::sys_common::backtrace::__rust_begin_short_backtrace::h44b264e90518e6aa
  18:     0x561363edc489 - std::rt::lang_start::{{closure}}::hf92ba4f93a08128a
  19:     0x561363effec6 - std::rt::lang_start_internal::hbeed09ea1fc92c20
  20:     0x561363edc467 - std::rt::lang_start::h2b98a589fffc6873

@thomcc
Copy link
Member

thomcc commented Feb 1, 2024

I'm going to be away for a few months, so I'm rerolling my PRs so that folks don't have to wait for me. Sorry/thanks.

r? libs

@cuviper
Copy link
Member

cuviper commented Feb 8, 2024

Removing this from my review queue while you're waiting for hashbrown...

@rustbot author

@rustbot rustbot 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-review Status: Awaiting review from the assignee but also interested parties. labels Feb 8, 2024
bors added a commit to rust-lang/hashbrown that referenced this pull request Feb 18, 2024
@Dylan-DPC
Copy link
Member

@SUPERCILEX any updates on this? thanks

@SUPERCILEX
Copy link
Contributor Author

@Dylan-DPC the hashbrown PR was merged. @Amanieu What are the next steps?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-libs Relevant to the library team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Entry API equivalent for Sets
7 participants