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

Remove helper-methods from Alloc trait and add associated Err type. #60771

Open
wants to merge 4 commits into
base: master
from

Conversation

@lachlansneff
Copy link

commented May 12, 2019

This PR removes the alloc_one, dealloc_one, alloc_array, and dealloc_array methods from the Alloc trait (as discussed in wg-allocators/#18) and adds an associated Err type (as discussed in wg-allocators/#23).

The CollectionAllocErr enum is now generic on E, the error type.

@rust-highfive

This comment has been minimized.

Copy link
Collaborator

commented May 12, 2019

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @aidanhs (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see the contribution instructions for more information.

@rust-highfive

This comment was marked as outdated.

Copy link
Collaborator

commented May 12, 2019

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:09abd4fa:start=1557698943521009521,finish=1557698944929801356,duration=1408791835
$ 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
$ export AWS_ACCESS_KEY_ID=AKIA46X5W6CZEJZ6XT55
---

[00:04:54] travis_fold:start:tidy
travis_time:start:tidy
tidy check
[00:04:55] tidy error: /checkout/src/liballoc/raw_vec.rs:323: line longer than 100 chars
[00:04:55] tidy error: /checkout/src/liballoc/alloc.rs:150: trailing whitespace
[00:05:00] some tidy checks failed
[00:05:00] 
[00:05:00] 
[00:05:00] command did not execute successfully: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-tools-bin/tidy" "/checkout/src" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0/bin/cargo" "--no-vendor" "--quiet"
[00:05:00] 
[00:05:00] 
[00:05:00] failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test src/tools/tidy
[00:05:00] Build completed unsuccessfully in 0:01:14
[00:05:00] Build completed unsuccessfully in 0:01:14
[00:05:00] make: *** [tidy] Error 1
[00:05:00] Makefile:67: recipe for target 'tidy' failed
The command "stamp sh -x -c "$RUN_SCRIPT"" exited with 2.
travis_time:start:0d7349ac
$ date && (curl -fs --head https://google.com | grep ^Date: | sed 's/Date: //g' || true)
Sun May 12 22:14:16 UTC 2019
---
travis_time:end:151265c8:start=1557699257128049056,finish=1557699257133325065,duration=5276009
travis_fold:end:after_failure.3
travis_fold:start:after_failure.4
travis_time:start:26d00224
$ 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:325e2e28
travis_time:start:325e2e28
$ 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

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)

@rust-highfive

This comment was marked as outdated.

Copy link
Collaborator

commented May 12, 2019

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:0d8fe389:start=1557699909817230431,finish=1557699910600900221,duration=783669790
$ 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
$ export AWS_ACCESS_KEY_ID=AKIA46X5W6CZEJZ6XT55
---
[00:05:21]     |
[00:05:21] 138 | unsafe impl Alloc for System {
[00:05:21]     | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `Err` in implementation
[00:05:21]     |
[00:05:21]     = note: `Err` from trait: `type Err;`
[00:05:21] error: aborting due to previous error
[00:05:21] 
[00:05:21] For more information about this error, try `rustc --explain E0046`.
[00:05:21] error: Could not compile `std`.

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)

@rust-highfive

This comment has been minimized.

Copy link
Collaborator

commented May 13, 2019

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:077ae3bc:start=1557701249335574718,finish=1557701250128264460,duration=792689742
$ 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
$ export AWS_ACCESS_KEY_ID=AKIA46X5W6CZEJZ6XT55
---
travis_time:start:test_run-pass
Check compiletest suite=run-pass mode=run-pass (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
[01:16:44] 
[01:16:44] running 2960 tests
[01:16:57] ......F............................................................................................. 100/2960
[01:17:19] .................................................................................................... 300/2960
[01:17:31] .................................................................................................... 400/2960
[01:17:41] .................................................................................................... 500/2960
[01:17:53] .................................................................................................... 600/2960
---
[01:23:37] failures:
[01:23:37] 
[01:23:37] ---- [run-pass] run-pass/allocator-alloc-one.rs stdout ----
[01:23:37] 
[01:23:37] error: test compilation failed although it shouldn't!
[01:23:37] status: exit code: 1
[01:23:37] command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/run-pass/allocator-alloc-one.rs" "-Zthreads=1" "--target=x86_64-unknown-linux-gnu" "--error-format" "json" "-Zui-testing" "-C" "prefer-dynamic" "-o" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/run-pass/allocator-alloc-one/a" "-Crpath" "-O" "-Zunstable-options" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/run-pass/allocator-alloc-one/auxiliary"
[01:23:37] ------------------------------------------
[01:23:37] 
[01:23:37] ------------------------------------------
[01:23:37] stderr:
[01:23:37] stderr:
[01:23:37] ------------------------------------------
[01:23:37] warning: unused import: `Alloc`
[01:23:37]   --> /checkout/src/test/run-pass/allocator-alloc-one.rs:5:18
[01:23:37]    |
[01:23:37] LL | use std::alloc::{Alloc, Global, Layout, handle_alloc_error};
[01:23:37]    |
[01:23:37]    = note: #[warn(unused_imports)] on by default
[01:23:37] 
[01:23:37] error[E0599]: no method named `alloc_one` found for type `std::alloc::Global` in the current scope
---
[01:23:37] thread 'main' panicked at 'Some tests failed', src/tools/compiletest/src/main.rs:512:22
[01:23:37] note: Run with `RUST_BACKTRACE=1` environment variable to display a backtrace.
[01:23:37] 
[01:23:37] 
[01:23:37] command did not execute successfully: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-tools-bin/compiletest" "--compile-lib-path" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib" "--run-lib-path" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/x86_64-unknown-linux-gnu/lib" "--rustc-path" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "--src-base" "/checkout/src/test/run-pass" "--build-base" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/run-pass" "--stage-id" "stage2-x86_64-unknown-linux-gnu" "--mode" "run-pass" "--target" "x86_64-unknown-linux-gnu" "--host" "x86_64-unknown-linux-gnu" "--llvm-filecheck" "/usr/lib/llvm-6.0/bin/FileCheck" "--host-rustcflags" "-Crpath -O -Zunstable-options  -Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "--target-rustcflags" "-Crpath -O -Zunstable-options  -Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "--docck-python" "/usr/bin/python2.7" "--lldb-python" "/usr/bin/python2.7" "--gdb" "/usr/bin/gdb" "--quiet" "--llvm-version" "6.0.0\n" "--system-llvm" "--cc" "" "--cxx" "" "--cflags" "" "--llvm-components" "" "--llvm-cxxflags" "" "--adb-path" "adb" "--adb-test-dir" "/data/tmp/work" "--android-cross-path" "" "--color" "always"
[01:23:37] 
[01:23:37] 
[01:23:37] failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test
[01:23:37] Build completed unsuccessfully in 0:11:46
[01:23:37] Build completed unsuccessfully in 0:11:46
[01:23:37] Makefile:48: recipe for target 'check' failed
[01:23:37] make: *** [check] Error 1
The command "stamp sh -x -c "$RUN_SCRIPT"" exited with 2.
travis_time:start:1bea33ff
$ date && (curl -fs --head https://google.com | grep ^Date: | sed 's/Date: //g' || true)
Mon May 13 00:11:18 UTC 2019
---
travis_time:end:273b4dcc:start=1557706279668799713,finish=1557706279673916156,duration=5116443
travis_fold:end:after_failure.3
travis_fold:start:after_failure.4
travis_time:start:06150a58
$ 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:0425ec62
travis_time:start:0425ec62
$ 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:1561f458
$ 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)

@Dylan-DPC

This comment has been minimized.

Copy link
Member

commented May 20, 2019

ping from triage @aidanhs waiting for your review on this @lachlansneff you have failing tests to resolve.

@jonas-schievink

This comment has been minimized.

Copy link
Member

commented Jun 18, 2019

Ping from triage again! Same status as last time, I believe. @lachlansneff can you address the test failure?

@Dylan-DPC

This comment has been minimized.

Copy link
Member

commented Jul 8, 2019

ping from triage
r? @SimonSapin

@rust-highfive rust-highfive assigned SimonSapin and unassigned aidanhs Jul 8, 2019

@SimonSapin

This comment has been minimized.

Copy link
Contributor

commented Jul 8, 2019

I don’t believe there is consensus so far for adding this associated type. (Or that the Allocators WG really has a way to reach it at all, yet. See rust-lang/wg-allocators#20.) So implementing that change doesn’t seem appropriate to me at this time.

As already argued in other threads, I personally don’t feel that having implementations of the Alloc trait return Result<_, !> is ever desirable. Instead, I would prefer that calling handle_alloc_error is the responsibility of separate APIs that wrap a generic A: Alloc handle, or take it as a parameter.

As to a non-zero-size inhabited error type, as far as I know we have yet to see a concrete use case for an allocator implementation to provide more information about a failure. This feels like a theoretical exercise is making a maximally general API.


Removing default methods on the other hand sounds fine to me. They would be easy to restore later if we decide to.

@Dylan-DPC

This comment has been minimized.

Copy link
Member

commented Jul 8, 2019

thanks. marking this as "waiting on team" till there is some consensus on the associated type

@bors

This comment has been minimized.

Copy link
Contributor

commented Jul 25, 2019

☔️ The latest upstream changes (presumably #60340) made this pull request unmergeable. Please resolve the merge conflicts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
7 participants
You can’t perform that action at this time.