-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Fix Debug implementations of some of the HashMap and BTreeMap iterator types #75377
Conversation
Deriving debug prints all the values including keys. But ValuesMut struct should only print the values.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please also remove the unused bound from the Debug impls of hash_map::IntoKeys and hash_map::IntoValues.
@rfcbot fcp merge This PR relaxes the bounds on the following stable Debug impls: impl<K, V> Debug for std::collections::btree_map::ValuesMut<'_, K, V>
where
- K: Debug,
V: Debug;
impl<K, V> Debug for std::collections::hash_map::ValuesMut<'_, K, V>
where
- K: Debug,
V: Debug; It also does the same for these, though all of these are unstable types: impl<K, V> Debug for std::collections::btree_map::IntoKeys<K, V>
where
K: Debug,
- V: Debug;
impl<K, V> Debug for std::collections::btree_map::IntoValues<K, V>
where
- K: Debug,
V: Debug;
impl<K, V> Debug for std::collections::hash_map::IntoKeys<K, V>
where
K: Debug,
- V: Debug;
impl<K, V> Debug for std::collections::hash_map::IntoValues<K, V>
where
- K: Debug,
V: Debug; This matches the existing signatures of the Debug impls on these stable types:
|
Team member @dtolnay has proposed to merge this. The next step is review by the rest of the tagged team members: No concerns currently listed. Once a majority of reviewers approve (and at most 2 approvals are outstanding), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up! See this document for info about what commands tagged team members can give me. |
Updated the bounds of |
@KodrAus @SimonSapin @withoutboats this is waiting for your vote/concerns on the fcp |
🔔 This is now entering its final comment period, as per the review above. 🔔 |
@bors r+ |
📌 Commit 8faf550 has been approved by |
⌛ Testing commit 8faf550 with merge ef1001a2ff6c8deceed8a0478c665aee1426368b... |
💔 Test failed - checks-azure |
Hey @dtolnay, I don't see any failure related to the PR. Do you think I need to do something else before merging this? |
Spurious network error:
|
@bors retry |
…as-schievink Rollup of 8 pull requests Successful merges: - rust-lang#75377 (Fix Debug implementations of some of the HashMap and BTreeMap iterator types) - rust-lang#76107 (Write manifest for MAJOR.MINOR channel to enable rustup convenience) - rust-lang#76745 (Move Wrapping<T> ui tests into library) - rust-lang#77182 (Add missing examples for Fd traits) - rust-lang#77251 (Bypass const_item_mutation if const's type has Drop impl) - rust-lang#77264 (Only use LOCAL_{STDOUT,STDERR} when set_{print/panic} is used. ) - rust-lang#77421 (Revert "resolve: Avoid "self-confirming" import resolutions in one more case") - rust-lang#77452 (Permit ty::Bool in const generics for v0 mangling) Failed merges: r? `@ghost`
HashMap's
ValuesMut
, BTreeMapsValuesMut
, IntoValues andIntoKeys
structs were printing both keys and values on their Debug implementations. But they are iterators over either keys or values. Irrelevant values should not be visible. With this PR, they only show relevant fields.This fixes #75297.
Here's an example code. This prints this on nightly:
After the patch this example prints these instead:
I didn't add test cases for them, since I couldn't see any tests for Debug implementations anywhere. But please let me know if I should add it to a specific place.
r? @dtolnay