-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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 {HashMap,HashSet} to std's prelude #63418
Conversation
@@ -123,3 +123,6 @@ pub use crate::string::{String, ToString}; | |||
#[stable(feature = "rust1", since = "1.0.0")] | |||
#[doc(no_inline)] | |||
pub use crate::vec::Vec; | |||
#[unstable(feature = "hashmap_prelude", issue = "0")] |
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.
@petrochenkov Does this have any effect? Probably not?
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.
It has effect on documentation.
(It will also have effect if someone bothers to move stability checking to its proper place - resolve.)
This comment has been minimized.
This comment has been minimized.
f1cb215
to
b46f828
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
fd466cb
to
ffb85f3
Compare
This comment has been minimized.
This comment has been minimized.
I cannot run the full test suite with x.py in local machine because of #63436. |
// The file so far is equivalent to src/libcore/prelude/v1.rs, | ||
// and below to src/liballoc/prelude.rs. | ||
// The file so far is equivalent to `src/libcore/prelude/v1.rs`, | ||
// and below to `src/liballoc/prelude/v1.rs` (except `HashMap`). | ||
// Those files are duplicated rather than using glob imports | ||
// because we want docs to show these re-exports as pointing to within `std`. |
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.
Should I remove these comments or not? @RalfJung
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.
Sorry, no idea. I just observed an inconsistency.
I hardly ever run more than |
I don't personally think HashMap is used often enough to deserve a spot in the prelude. |
IMO we should rethink the prelude and not have it be so limited. I think the bar set by:
is just too high. For example, I do not think that |
I think that messing with something so important, and that affects imports to every single program, is something to be done with extreme care. |
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.
Typo: HashpMap should be HashMap
I'd love to see this happen. I'm concerned about it generating warnings about redundant imports, as evidenced by the extensive test suite changes, but I don't see any reasonable way around that. |
Could you please rebase the series and squash some patches together to avoid fixing bugs introduced by the same series? For instance, you have several commits making the same kind of change to tests, and you have a commit changing a test incorrectly followed by a commit fixing the test correctly. |
We discussed this in the lang team meeting, and we developed a consensus that the lang team wants to defer decisions about the content of the prelude to the libs team, unless the libs team specifically wants to consult the lang team (such as for issues of coherence or alignment with new language features). As such, un-tagging the lang team. |
Now, taking my lang team hat off and speaking only for myself: Yes, please, I'd love to see HashMap in the prelude. I'd also like to see a few other things added to the prelude that people commonly use. We'll need to take some care about traits, but types should not cause issues to introduce. |
ac72da7
to
c066237
Compare
I always use it when going from |
I've been bitten by that quite badly when, for some reason, I ended up with an |
I'm having trouble imagining a situation where I'd use (If the borrow checker is happy with a reference, then why would I be calling ...and, in that case, I'd say that it's a good thing for the same reason that I don't want string+integer concatenation doing automatic type conversion. As far as I'm concerned, if |
I disagree, I think if what I want is a string I should express that -- "to owned" doesn't convey enough information about what we own then. This is related to accidentally cloning a shared reference instead of what it points to. But I'll stop digressing here now. ;) |
Fair enough. I won't keep things off-topic either but I will say that I hadn't considered shared references. (I'm still used to choosing project ideas where Rust is just serving as a more maintainable alternative to Python and, given Python's Global Interpreter Lock, that means I don't do much parallel stuff.) |
Quite apart from the question of what items are in the prelude: I had understood that if items were added to the prelude in future, they’d be in a different module than |
* Fix `HashMap` redundantly import errors * Replace HashMap by BTreeMap in tests suggested by Jonas
c066237
to
0fb8f5f
Compare
Thanks for the PR! I'm a bit lost reading this PR though. None of the description, the commits, or the discussion thread seem to discuss the motivation here for why |
☔ The latest upstream changes (presumably #63870) made this pull request unmergeable. Please resolve the merge conflicts. |
I'm going to close this because this change needs an accepted RFC which hasn't happened, but feel free to ping if assistance is needed in writing an RFC! |
r? @Centril