Skip to content

Add the alloc::prelude module #52119

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

Closed
wants to merge 2 commits into from
Closed

Add the alloc::prelude module #52119

wants to merge 2 commits into from

Conversation

SimonSapin
Copy link
Contributor

@SimonSapin SimonSapin commented Jul 6, 2018

It contains the re-exports that are in std::prelude::v1 but not in core::prelude::v1.

Calling it prelude is somewhat of a misnomer since (unlike those modules in std or core) its contents are never implicitly imported in modules. Rather it is intended to be used with an explicit glob import like use alloc::prelude::*;. However there is precedent for the same misnomer with std::io::prelude, for example.

This new module is unstable with the same feature name as the alloc care. They are proposed for stabilization together in RFC rust-lang/rfcs#2480.

@rust-highfive
Copy link
Contributor

r? @shepmaster

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

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jul 6, 2018
@rust-highfive
Copy link
Contributor

The job x86_64-gnu-llvm-3.9 of your PR failed on Travis (raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log.
[01:13:46] 
[01:13:46] 
[01:13:46] running 399 tests
[01:14:15] ....................................................................................................
[01:14:38] ...................................................................i................F...............
[01:15:19] ...................................................................................................
[01:15:19] failures:
[01:15:19] 
[01:15:19] ---- prelude.rs - prelude (line 16) stdout ----
[01:15:19] ---- prelude.rs - prelude (line 16) stdout ----
[01:15:19] error[E0433]: failed to resolve. Did you mean `std::alloc`?
[01:15:19]  --> prelude.rs:18:5
[01:15:19] 5 | use alloc::prelude::*;
[01:15:19]   |     ^^^^^ Did you mean `std::alloc`?
[01:15:19] 
[01:15:19] thread 'prelude.rs - prelude (line 16)' panicked at 'couldn't compile the test', librustdoc/test.rs:327:17
---
[01:15:19] 
[01:15:19] error: test failed, to rerun pass '--doc'
[01:15:19] 
[01:15:19] 
[01:15:19] command did not execute successfully: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0/bin/cargo" "test" "--target" "x86_64-unknown-linux-gnu" "-j" "4" "--release" "--locked" "--color" "always" "--features" "panic-unwind jemalloc backtrace" "--manifest-path" "/checkout/src/libstd/Cargo.toml" "-p" "alloc" "--" "--quiet"
[01:15:19] 
[01:15:19] 
[01:15:19] failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test
[01:15:19] Build completed unsuccessfully in 0:29:28
[01:15:19] Build completed unsuccessfully in 0:29:28
[01:15:19] make: *** [check] Error 1
[01:15:19] Makefile:58: recipe for target 'check' failed
2842592 ./obj
2840232 ./obj/build
2245784 ./obj/build/x86_64-unknown-linux-gnu
730396 ./src
---
144184 ./obj/build/bootstrap/debug/incremental
143672 ./obj/build/x86_64-unknown-linux-gnu/stage1-rustc/x86_64-unknown-linux-gnu
143668 ./obj/build/x86_64-unknown-linux-gnu/stage1-rustc/x86_64-unknown-linux-gnu/release
129672 ./obj/build/bootstrap/debug/incremental/bootstrap-nf9tlms0eza
129668 ./obj/build/bootstrap/debug/incremental/bootstrap-nf9tlms0eza/s-f2nxwxmvrw-820vkd-jf8cfeolaswv
129452 ./obj/build/x86linux-gnu/stage2-tools
60840 ./src/llvm-emscripten/lib
60776 ./obj/build/x86_64-unknown-linux-gnu/stage0-rustc
57604 ./obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu

I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact @TimNN. (Feature Requests)

@shepmaster
Copy link
Member

I swear I always get the "insta-stable" PRs... 😝

r? @alexcrichton

@SimonSapin
Copy link
Contributor Author

Yeah, I may be cutting a corner here. I don’t mind changing this to unstable and proposing stabilization together with the crate in rust-lang/rfcs#2480.

It contains the re-exports that are in `std::prelude::v1`
but not in `core::prelude::v1`.

Calling it prelude is somewhat of a misnomer since (unlike those modules
in `std` or `core`) its contents are never implicitly imported in modules.
Rather it is intended to be used with an explicit glob import like
`use alloc::prelude::*;`.
However there is precedent for the same misnomer with `std::io::prelude`,
for example.

This new module is unstable with the same feature name as the `alloc` care.
They are proposed for stabilization together in RFC
rust-lang/rfcs#2480
@SimonSapin
Copy link
Contributor Author

Changed to unstable with the same feature name as the crate.

@alexcrichton
Copy link
Member

I'm still not 100% sure this is the end state we want to be in, but I think this is a good option to have at least. In any case it's an unstable module so we have time to tinker! Should this perhaps follow the standard of core/std prelude and be in a v1 submodule as well?

@SimonSapin
Copy link
Contributor Author

It’s not injected automatically anywhere, so I rather followed the example of std::io::prelude, std::os::windows::prelude, etc.

@alexcrichton alexcrichton deleted the alloc-prelude branch July 8, 2018 15:47
@alexcrichton
Copy link
Member

Er sorry, was cleaning out branches on the rust-lang repo and accidentally closed this, can the PR be resent from your own repo @SimonSapin?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants