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

Move alloc::prelude::* to alloc::prelude::v1, make alloc a subset of std #58933

Merged
merged 2 commits into from
Mar 16, 2019

Conversation

SimonSapin
Copy link
Contributor

@SimonSapin SimonSapin commented Mar 5, 2019

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 #58175.

Also rename the feature gate and point to a dedicated tracking issue: #58935

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
@rust-highfive
Copy link
Collaborator

r? @joshtriplett

(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 Mar 5, 2019
@SimonSapin
Copy link
Contributor Author

This is a breaking change to unstable APIs. CC @Nemo157, @dhardy, @alexcrichton, and @tarcieri who were involved in related discussions in rust-lang/rfcs#2480.

@SimonSapin
Copy link
Contributor Author

I previously argued the other way around:

this not using a v1 submodule in order to follow the precedent of std::io::prelude rather than that of std::prelude::v1, since this import is never inserted automatically.

But I’ve changed my mind, I think making the crate actually a subset of std is more valuable.

@Nemo157
Copy link
Member

Nemo157 commented Mar 5, 2019

Big 👍 from me. This makes a very useful pattern possible while alloc is unstable, allowing easier opt-in experimentation on nightly:

#[cfg(all(feature = "alloc", not(feature = "std")))]
extern crate alloc;
#[cfg(feature = "std")]
extern crate std as alloc;

@rust-highfive
Copy link
Collaborator

The job x86_64-gnu-llvm-6.0 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.
travis_time:end:0b3a6bf4:start=1551782993320238380,finish=1551782994396548827,duration=1076310447
$ git checkout -qf FETCH_HEAD
travis_fold:end:git.checkout

Encrypted environment variables have been removed for security reasons.
See https://docs.travis-ci.com/user/pull-requests/#pull-requests-and-security-restrictions
$ export SCCACHE_BUCKET=rust-lang-ci-sccache2
$ export SCCACHE_REGION=us-west-1
$ export GCP_CACHE_BUCKET=rust-lang-ci-cache
Setting environment variables from .travis.yml
---
travis_time:start:test_debuginfo
Check compiletest suite=debuginfo mode=debuginfo-both (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
[01:21:46] 
[01:21:46] running 119 tests
[01:22:15] .iiiii...i.....i..i...i..i.i..i.ii...i.....i..i....i..........iiii..........i...ii...i.......ii.i.i. 100/119
[01:22:20] i......iii.i.....ii
[01:22:20] 
[01:22:20]  finished in 34.396
[01:22:20] travis_fold:end:test_debuginfo

---
[01:31:03] 
[01:31:04] 
[01:31:04] running 419 tests
[01:31:24] .................................................................................................... 100/419
[01:31:40] .............................................................................i..............F....... 200/419
[01:32:08] .................................................................................................... 400/419
[01:32:11] ...................
[01:32:11] failures:
[01:32:11] 
[01:32:11] 
[01:32:11] ---- prelude/mod.rs - prelude (line 6) stdout ----
[01:32:11] error[E0658]: use of unstable library feature 'alloc_prelude' (see issue #58935)
[01:32:11]  --> prelude/mod.rs:10:5
[01:32:11]   |
[01:32:11] 7 | use alloc::prelude::v1::*;
[01:32:11]   |
[01:32:11]   = help: add #![feature(alloc_prelude)] to the crate attributes to enable
[01:32:11] 
[01:32:11] thread 'prelude/mod.rs - prelude (line 6)' panicked at 'couldn't compile the test', src/librustdoc/test.rs:352:13
---
[01:32:11] 
[01:32:11] error: test failed, to rerun pass '--doc'
[01:32:11] 
[01:32:11] 
[01:32:11] 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 backtrace" "--manifest-path" "/checkout/src/libstd/Cargo.toml" "-p" "alloc" "--" "--quiet"
[01:32:11] 
[01:32:11] 
[01:32:11] failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test
[01:32:11] Build completed unsuccessfully in 0:23:11
[01:32:11] Build completed unsuccessfully in 0:23:11
[01:32:11] Makefile:48: recipe for target 'check' failed
[01:32:11] make: *** [check] Error 1
The command "stamp sh -x -c "$RUN_SCRIPT"" exited with 2.
travis_time:start:0107cf04
$ date && (curl -fs --head https://google.com | grep ^Date: | sed 's/Date: //g' || true)
Tue Mar  5 12:22:16 UTC 2019
---
travis_time:end:0890a207:start=1551788538949106424,finish=1551788538955073105,duration=5966681
travis_fold:end:after_failure.3
travis_fold:start:after_failure.4
travis_time:start:22c2b7ec
$ ln -s . checkout && for CORE in obj/cores/core.*; do EXE=$(echo $CORE | sed 's|obj/cores/core\.[0-9]*\.!checkout!\(.*\)|\1|;y|!|/|'); if [ -f "$EXE" ]; then printf travis_fold":start:crashlog\n\033[31;1m%s\033[0m\n" "$CORE"; gdb --batch -q -c "$CORE" "$EXE" -iex 'set auto-load off' -iex 'dir src/' -iex 'set sysroot .' -ex bt -ex q; echo travis_fold":"end:crashlog; fi; done || true
travis_fold:end:after_failure.4
travis_fold:start:after_failure.5
travis_time:start:0384bae4
travis_time:start:0384bae4
$ cat ./obj/build/x86_64-unknown-linux-gnu/native/asan/build/lib/asan/clang_rt.asan-dynamic-i386.vers || true
cat: ./obj/build/x86_64-unknown-linux-gnu/native/asan/build/lib/asan/clang_rt.asan-dynamic-i386.vers: No such file or directory
travis_fold:end:after_failure.5
travis_fold:start:after_failure.6
travis_time:start:1fd297e4
$ dmesg | grep -i kill

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)

… to separate it from that of the crate.

New tracking issue: rust-lang#58935
@tarcieri
Copy link
Contributor

tarcieri commented Mar 5, 2019

👍 from me as well. I wound up using this feature a bunch, and have this in several crates:

#[cfg(all(feature = "alloc", not(feature = "std")))]
pub use alloc::prelude::*;

I guess this change will break all those crates, but hey, that's what I signed up for so I'm not complaining 😉 and if it helps simplify the story around alloc stabilization, I'm all for it.

@dhardy
Copy link
Contributor

dhardy commented Mar 5, 2019

I don't think this affects me directly, but definitely support making alloc a subset of std. 👍

@Amanieu
Copy link
Member

Amanieu commented Mar 12, 2019

@bors r+

@bors
Copy link
Contributor

bors commented Mar 12, 2019

📌 Commit 5d1022a has been approved by Amanieu

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Mar 12, 2019
kennytm added a commit to kennytm/rust that referenced this pull request 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 pull request 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
bors added a commit that referenced this pull request Mar 16, 2019
Rollup of 37 pull requests

Successful merges:

 - #58854 (appveyor: Use VS2017 for all our images)
 - #58855 (std: Spin for a global malloc lock on wasm32)
 - #58873 (Fix "Auto-hide item methods documentation" setting)
 - #58901 (Change `std::fs::copy` to use `copyfile` on MacOS and iOS)
 - #58933 (Move alloc::prelude::* to alloc::prelude::v1, make alloc a subset of std)
 - #58938 (core: ensure VaList passes improper_ctypes lint)
 - #58941 (MIPS: add r6 support)
 - #58949 (SGX target: Expose thread id function in os module)
 - #58959 (Add release notes for PR #56243)
 - #58976 (Default to integrated `rust-lld` linker for UEFI targets)
 - #59009 (Fix SGX implementations of read/write_vectored.)
 - #59025 (Fix generic argument lookup for Self)
 - #59036 (Fix ICE in MIR pretty printing)
 - #59037 (Avoid some common false positives in intra doc link checking)
 - #59072 (we can now skip should_panic tests with the libtest harness)
 - #59079 (add suggestions to invalid macro item error)
 - #59082 (A few improvements to comments in user-facing crates)
 - #59102 (Consistent naming for duration_float methods and additional f32 methods)
 - #59118 (rustc: fix ICE when trait alias has bare Self)
 - #59139 (Unregress using scalar unions in constants.)
 - #59146 (Suggest return lifetime when there's only one named lifetime)
 - #59147 (Make std time tests more robust for platform differences)
 - #59152 (Stabilize Range*::contains.)
 - #59156 ([wg-async-await] Add regression test for #55809.)
 - #59158 (Revert "Don't generate minification variable if minification disabled")
 - #59169 (Add `-Z allow_features=...` flag)
 - #59173 (bootstrap: Default to a sensible llvm-suffix.)
 - #59175 (Don't run test launching `echo` since that doesn't exist on Windows)
 - #59180 (Use try blocks in rustc_codegen_ssa)
 - #59185 (No old chestnuts in iter::repeat docs)
 - #59201 (Remove restriction on isize/usize in repr(simd))
 - #59204 (Output diagnostic information for rustdoc)
 - #59206 (Improved test output)
 - #59208 (Reduce a Code Repetition Related to Bit Operation)
 - #59212 (Add x86_64 musl host to the manifest)
 - #59221 (Option and Result: Add references to documentation of as_ref and as_mut)
 - #59231 (Stabilize Option::copied)
@bors bors merged commit 5d1022a into rust-lang:master Mar 16, 2019
@SimonSapin SimonSapin deleted the alloc-prelude-v1 branch November 28, 2019 12:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants