-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Edition-specific preludes #82217
Edition-specific preludes #82217
Conversation
r? @sfackler (rust-highfive has picked a reviewer for you, use r? to override) |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Yes, but |
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.
Nice. Could the documentation in of ::std::prelude
be adapted too? It uses single-prelude terminology like "the current version of the prelude":
rust/library/std/src/prelude/mod.rs
Line 28 in ee88f46
//! The current version of the prelude (version 1) lives in |
pub use super::v1::*; | ||
|
||
#[unstable(feature = "prelude_2021", issue = "none")] | ||
#[doc(no_inline)] |
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.
(Can always be done later) Could this be done for the other editions as well? If only, I think it will be nice to have such a line appear on the documentation of these preludes.
I don't think we should do that yet. These new names for the preludes are unstable, and edition 2021 is also not yet stable. So |
☔ The latest upstream changes (presumably #82281) made this pull request unmergeable. Please resolve the merge conflicts. |
src/test/ui/imports/extern-prelude-extern-crate-restricted-shadowing.stderr
Show resolved
Hide resolved
rust_2015 and rust_2018 are just re-exports of v1. rust_2021 is a module that for now just re-exports everything from v1, such that we can add more things later.
Co-authored-by: Joshua Nelson <[email protected]>
b1b58af
to
76fd8d7
Compare
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.
The code looks good to me.
@bors r+ |
📌 Commit 76fd8d7 has been approved by |
…akis Edition-specific preludes This changes `{std,core}::prelude` to export edition-specific preludes under `rust_2015`, `rust_2018` and `rust_2021`. (As suggested in rust-lang#51418 (comment).) For now they all just re-export `v1::*`, but this allows us to add things to the 2021edition prelude soon. This also changes the compiler to make the automatically injected prelude import dependent on the selected edition. cc `@rust-lang/libs` `@djc`
@estebank If you have time, I could use some help here. Somehow the E0573 diagnostic suggests to use use std::result;
impl result {
fn into_future() -> Err {}
}
fn main() {}
|
This is now blocked on #82942 |
@m-ou-se the ping is resolved by the open PR, right? |
@estebank Yes. I'm still curious why it picks the |
…de-v1, r=estebank Don't hardcode the `v1` prelude in diagnostics, to allow for new preludes. Instead of looking for `std::prelude::v1`, this changes the two places where that was hardcoded to look for `std::prelude::<anything>` instead. This is needed for rust-lang#82217. r? `@estebank`
📌 Commit 76fd8d7 has been approved by |
Rollup of 9 pull requests Successful merges: - rust-lang#81309 (always eagerly eval consts in Relate) - rust-lang#82217 (Edition-specific preludes) - rust-lang#82807 (rustdoc: Remove redundant enableSearchInput function) - rust-lang#82924 (WASI: Switch to crt1-command.o to enable support for new-style commands) - rust-lang#82949 (Do not attempt to unlock envlock in child process after a fork.) - rust-lang#82955 (fix: wrong word) - rust-lang#82962 (Treat header as first paragraph for shortened markdown descriptions) - rust-lang#82976 (fix error message for copy(_nonoverlapping) overflow) - rust-lang#82977 (Rename `Option::get_or_default` to `get_or_insert_default`) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
This changes
{std,core}::prelude
to export edition-specific preludes underrust_2015
,rust_2018
andrust_2021
. (As suggested in #51418 (comment).) For now they all just re-exportv1::*
, but this allows us to add things to the 2021edition prelude soon.This also changes the compiler to make the automatically injected prelude import dependent on the selected edition.
cc @rust-lang/libs @djc