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

Closed
wants to merge 4 commits into from

Conversation

lachlansneff
Copy link

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
Copy link
Collaborator

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 rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label May 12, 2019
@rust-highfive

This comment has been minimized.

@rust-highfive

This comment has been minimized.

@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: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-zz
Copy link

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

@jonas-schievink
Copy link
Contributor

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

@Dylan-DPC-zz
Copy link

ping from triage
r? @SimonSapin

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

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-zz
Copy link

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

@Dylan-DPC-zz Dylan-DPC-zz added S-waiting-on-team Status: Awaiting decision from the relevant subteam (see the T-<team> label). and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jul 8, 2019
@bors
Copy link
Contributor

bors commented Jul 25, 2019

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

@JohnCSimon JohnCSimon added the S-inactive Status: Inactive and waiting on the author. This is often applied to closed PRs. label Oct 12, 2019
@JohnCSimon JohnCSimon closed this Oct 12, 2019
@apiraino apiraino removed the S-waiting-on-team Status: Awaiting decision from the relevant subteam (see the T-<team> label). label May 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-inactive Status: Inactive and waiting on the author. This is often applied to closed PRs.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants