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

Tracking issue for alloc::prelude #58935

Closed
SimonSapin opened this issue Mar 5, 2019 · 14 comments · Fixed by #89898
Closed

Tracking issue for alloc::prelude #58935

SimonSapin opened this issue Mar 5, 2019 · 14 comments · Fixed by #89898
Labels
B-unstable Blocker: Implemented in the nightly compiler and unstable. C-tracking-issue Category: A tracking issue for an RFC or an unstable feature. disposition-close This PR / issue is in PFCP or FCP with a disposition to close it. finished-final-comment-period The final comment period is finished for this PR / Issue. Libs-Tracked Libs issues that are tracked on the team's project board. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.

Comments

@SimonSapin
Copy link
Contributor

Its stability was separated from that of the alloc crate in #58933.

CC rust-lang/rfcs#2480

@SimonSapin SimonSapin added T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. B-unstable Blocker: Implemented in the nightly compiler and unstable. C-tracking-issue Category: A tracking issue for an RFC or an unstable feature. labels Mar 5, 2019
SimonSapin added a commit to SimonSapin/rust that referenced this issue Mar 5, 2019
… to separate it from that of the crate.

New tracking issue: rust-lang#58935
kennytm added a commit to kennytm/rust that referenced this issue Mar 15, 2019
Move alloc::prelude::* to alloc::prelude::v1, make alloc a subset of std

This was one of the unresolved questions of rust-lang/rfcs#2480. As the RFC says this is maybe not useful in the sense that we are unlikely to ever have a second version, but making the crate a true subset makes one less issue to think about if we stabilize it and later want to merge standard library crates and have Cargo feature flags to enable or disable parts of the `std` crate.

See also discussion in rust-lang#58175.

Also rename the feature gate and point to a dedicated tracking issue: rust-lang#58935
kennytm added a commit to kennytm/rust that referenced this issue Mar 16, 2019
Move alloc::prelude::* to alloc::prelude::v1, make alloc a subset of std

This was one of the unresolved questions of rust-lang/rfcs#2480. As the RFC says this is maybe not useful in the sense that we are unlikely to ever have a second version, but making the crate a true subset makes one less issue to think about if we stabilize it and later want to merge standard library crates and have Cargo feature flags to enable or disable parts of the `std` crate.

See also discussion in rust-lang#58175.

Also rename the feature gate and point to a dedicated tracking issue: rust-lang#58935
@roblabla
Copy link
Contributor

roblabla commented Jun 17, 2019

The alloc_prelude feature gate seems to be broken: https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=808681d68a06487853e5d2d3416fd332 compiles and runs just fine without specifying the #![feature(alloc_prelude)] feature gate.

@SimonSapin
Copy link
Contributor Author

This is a case of #15702.

(The documented example use alloc::prelude::v1::*; does require the feature gate.)

@LukasKalbertodt
Copy link
Member

What exactly is blocking stabilization? Any unresolved questions? Just gaining experience with it?

@SimonSapin
Copy link
Contributor Author

I think there was a question of how useful this is, since unlike core::prelude or std::prelude this isn’t injected automatically in any crate. Feedback from projects who use it despite this or would like to use it despite this would be helpful.

@LukasKalbertodt
Copy link
Member

I think it is very useful.

I commented here after trying to use alloc::prelude for stable-vec which is no_std with alloc. The crate started, as probably most no_std crates, as a normal crate with std. Thus, across the codebase I used symbols such as Vec. To make the transition to alloc as easy as possible, crates should be able to just use alloc::prelude::*; to not import symbols like Vec manually. Especially if the crate also has an std feature which conditionally uses std to enabled more features. Because in that later case, the crate would have to conditionally compile even more import statements, leading to a mess.

In the end, I stopped baking my own solution and used no-std-compat. But even that crate would benefit from a stable alloc::prelude. Look at this code:

pub mod prelude {
    pub mod v1 {
        // Prelude
        pub use __core::prelude::v1::*;
        #[cfg(all(feature = "alloc", feature = "unstable"))]
        pub use __alloc::prelude::v1::*;
        #[cfg(all(feature = "alloc", not(feature = "unstable")))]
        pub use __alloc::{
            borrow::ToOwned,
            boxed::Box,
            // UNSTABLE: slice::SliceConcatExt,
            string::String,
            string::ToString,
            vec::Vec,
        };

        // Other imports
        #[cfg(feature = "alloc")]
        pub use __alloc::{format, vec};
        #[cfg(feature = "compat_macros")]
        pub use crate::{print, println, eprint, eprintln, dbg};
    }
}

So if the unstable feature of that crate is not enabled, it has to manually list the prelude symbols.

So I think alloc::prelude is useful and I don't see a reason not to include it. I don't see how this could be abused/lead to worse code/could limit future developments of the language or the alloc crate. It just seems very natural to have. alloc is a subset of std, so I want alloc::prelude to be a subset of std::prelude.

@elichai
Copy link
Contributor

elichai commented Feb 24, 2020

I think there was a question of how useful this is, since unlike core::prelude or std::prelude this isn’t injected automatically in any crate.

Why not auto inject it if alloc is enabled?

@SimonSapin
Copy link
Contributor Author

This would add “more magic” to the language. It’s possible, but I feel it should go through the RFC process to get consensus of whether to go in that direction.

@elichai
Copy link
Contributor

elichai commented Feb 24, 2020

This would add “more magic” to the language. It’s possible, but I feel it should go through the RFC process to get consensus of whether to go in that direction.

I might actually try to write one(have no experience in writing RFCs) if you think it's needed.
I think it can make it really easier to add a alloc only feature for crates.(and more importantly maintain it)
(although maybe one day we could use the replace sysroot feature to somehow pass --alloc-only flag to the compiler which will auto-magically do this for us without editing the crate)

@jhpratt
Copy link
Member

jhpratt commented Jun 7, 2020

Is there any harm in stabilizing the module itself, then deciding whether to auto-import it at a later time? I'd like to be able to use the module, as right now I've literally code identical code in a module to import in the same manner.

@KodrAus KodrAus added the Libs-Tracked Libs issues that are tracked on the team's project board. label Jul 29, 2020
@Amanieu
Copy link
Member

Amanieu commented Sep 23, 2021

We discussed this in the libs meeting and felt that we shouldn't have a prelude module in alloc unless it is auto-imported like the preludes in core and std. This could be implemented in the future as an extension to #![no_std] such as #![no_std(alloc)] which would also remove the need for extern crate alloc.

Until such a feature is introduced, we don't think alloc::prelude should be stabilized.

@rfcbot close

@rfcbot
Copy link

rfcbot commented Sep 23, 2021

Team member @Amanieu has proposed to close 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.

@rfcbot rfcbot added proposed-final-comment-period Proposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off. disposition-close This PR / issue is in PFCP or FCP with a disposition to close it. labels Sep 23, 2021
@SimonSapin
Copy link
Contributor Author

an extension to #![no_std] such as #![no_std(alloc)] which would also remove the need for extern crate alloc

Oh I hadn’t heard of that idea before. It sounds nice!

@rfcbot rfcbot added the final-comment-period In the final comment period and will be merged soon unless new substantive objections are raised. label Sep 29, 2021
@rfcbot
Copy link

rfcbot commented Sep 29, 2021

🔔 This is now entering its final comment period, as per the review above. 🔔

@rfcbot rfcbot removed the proposed-final-comment-period Proposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off. label Sep 29, 2021
@rfcbot rfcbot added finished-final-comment-period The final comment period is finished for this PR / Issue. to-announce Announce this issue on triage meeting and removed final-comment-period In the final comment period and will be merged soon unless new substantive objections are raised. labels Oct 9, 2021
@rfcbot
Copy link

rfcbot commented Oct 9, 2021

The final comment period, with a disposition to close, as per the review above, is now complete.

As the automated representative of the governance process, I would like to thank the author for their work and everyone else who contributed.

matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Oct 15, 2021
…htriplett

Remove alloc::prelude

As per the libs team decision in rust-lang#58935.

Closes rust-lang#58935
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Oct 15, 2021
…htriplett

Remove alloc::prelude

As per the libs team decision in rust-lang#58935.

Closes rust-lang#58935
jackh726 added a commit to jackh726/rust that referenced this issue Oct 16, 2021
…htriplett

Remove alloc::prelude

As per the libs team decision in rust-lang#58935.

Closes rust-lang#58935
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Oct 16, 2021
…htriplett

Remove alloc::prelude

As per the libs team decision in rust-lang#58935.

Closes rust-lang#58935
@bors bors closed this as completed in 8007dfa Oct 16, 2021
@apiraino apiraino removed the to-announce Announce this issue on triage meeting label Oct 21, 2021
bors pushed a commit to rust-lang-ci/rust that referenced this issue Dec 20, 2021
As per the libs team decision in rust-lang#58935.

Closes rust-lang#58935
bjorn3 pushed a commit to bjorn3/rust that referenced this issue Dec 31, 2021
As per the libs team decision in rust-lang#58935.

Closes rust-lang#58935
bjorn3 pushed a commit to bjorn3/rust that referenced this issue Dec 31, 2021
* Rebase fallout.

* Move rustc_middle::middle::cstore to rustc_session.

* Create more accurate debuginfo for vtables.

Before this commit all vtables would have the same name "vtable" in
debuginfo. Now they get a name that identifies the implementing type
and the trait that is being implemented.

* Remove alloc::prelude

As per the libs team decision in rust-lang#58935.

Closes rust-lang#58935

* Make hash_result an Option.

* Properly check `target_features` not to trigger an assertion

* Add LLVM CFI support to the Rust compiler

This commit adds LLVM Control Flow Integrity (CFI) support to the Rust
compiler. It initially provides forward-edge control flow protection for
Rust-compiled code only by aggregating function pointers in groups
identified by their number of arguments.

Forward-edge control flow protection for C or C++ and Rust -compiled
code "mixed binaries" (i.e., for when C or C++ and Rust -compiled code
share the same virtual address space) will be provided in later work as
part of this project by defining and using compatible type identifiers
(see Type metadata in the design document in the tracking issue rust-lang#89653).

LLVM CFI can be enabled with -Zsanitizer=cfi and requires LTO (i.e.,
-Clto).

* Update to nightly-2021-10-30

* Add deduplication of constant values as rustc relies on LLVM doing that

Co-authored-by: Camille GILLOT <gillot.camille@gmail.com>
Co-authored-by: Michael Woerister <michaelwoerister@posteo>
Co-authored-by: Amanieu d'Antras <amanieu@gmail.com>
Co-authored-by: Yuki Okushi <yuki.okushi@huawei.com>
Co-authored-by: Ramon de C Valle <rcvalle@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
B-unstable Blocker: Implemented in the nightly compiler and unstable. C-tracking-issue Category: A tracking issue for an RFC or an unstable feature. disposition-close This PR / issue is in PFCP or FCP with a disposition to close it. finished-final-comment-period The final comment period is finished for this PR / Issue. Libs-Tracked Libs issues that are tracked on the team's project board. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants