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

Add ManuallyDrop::take #55421

Merged
merged 1 commit into from Oct 28, 2018

Conversation

Projects
None yet
6 participants
@CAD97
Contributor

CAD97 commented Oct 27, 2018

Tracking issue: #55422

Proposed in this form in https://internals.rust-lang.org/t/mini-rfc-manuallydrop-take/8679,
see that thread for some history.

A small convenience wrapper for ManuallyDrop that makes a pattern (taking ownership of the contained data in drop) more obvious.

@rust-highfive

This comment has been minimized.

Collaborator

rust-highfive commented Oct 27, 2018

r? @kennytm

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

@CAD97

This comment has been minimized.

Contributor

CAD97 commented Oct 27, 2018

Tracking issue currently points to this PR, that will need to be updated if this is accepted to be merged.

cc @scottmcm

@rust-highfive

This comment has been minimized.

Collaborator

rust-highfive commented Oct 27, 2018

The job x86_64-gnu-llvm-5.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:027d4d70:start=1540667294449047803,finish=1540667295441949262,duration=992901459
$ 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
Setting environment variables from .travis.yml
$ export SCCACHE_BUCKET=rust-lang-ci-sccache2
---
[00:04:06] tidy error: /checkout/src/libcore/mem.rs:976: trailing whitespace
[00:04:07] some tidy checks failed
[00:04:07] 
[00:04:07] 
[00:04:07] 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:04:07] 
[00:04:07] 
[00:04:07] failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test src/tools/tidy
[00:04:07] Build completed unsuccessfully in 0:00:49
[00:04:07] Build completed unsuccessfully in 0:00:49
[00:04:07] make: *** [tidy] Error 1
[00:04:07] Makefile:79: recipe for target 'tidy' failed

The command "stamp sh -x -c "$RUN_SCRIPT"" exited with 2.
travis_time:start:2f326b80
$ date && (curl -fs --head https://google.com | grep ^Date: | sed 's/Date: //g' || true)
---
travis_time:end:1f68a157:start=1540667553143689352,finish=1540667553148061163,duration=4371811
travis_fold:end:after_failure.3
travis_fold:start:after_failure.4
travis_time:start:0caa2906
$ 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:1e95a768
travis_time:start:1e95a768
$ 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:11d08ba6
$ 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)

@kennytm

Just some documentation issues otherwise LGTM 🙂. cc @scottmcm.

Show resolved Hide resolved src/libcore/mem.rs Outdated
Show resolved Hide resolved src/libcore/mem.rs Outdated
Show resolved Hide resolved src/libcore/mem.rs Outdated
Show resolved Hide resolved src/libcore/mem.rs Outdated
Show resolved Hide resolved src/libcore/mem.rs Outdated
@rust-highfive

This comment has been minimized.

Collaborator

rust-highfive commented Oct 27, 2018

The job x86_64-gnu-llvm-5.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:0a9cae5c:start=1540668777872306777,finish=1540668778909990888,duration=1037684111
$ 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
Setting environment variables from .travis.yml
$ export SCCACHE_BUCKET=rust-lang-ci-sccache2
---
[00:04:04] tidy error: /checkout/src/libcore/mem.rs:976: trailing whitespace
[00:04:05] some tidy checks failed
[00:04:05] 
[00:04:05] 
[00:04:05] 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:04:05] 
[00:04:05] 
[00:04:05] failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test src/tools/tidy
[00:04:05] Build completed unsuccessfully in 0:00:46
[00:04:05] Build completed unsuccessfully in 0:00:46
[00:04:05] Makefile:79: recipe for target 'tidy' failed
[00:04:05] make: *** [tidy] Error 1

The command "stamp sh -x -c "$RUN_SCRIPT"" exited with 2.
travis_time:start:0a577ea4
$ date && (curl -fs --head https://google.com | grep ^Date: | sed 's/Date: //g' || true)
---
travis_time:end:104849c8:start=1540669034745397128,finish=1540669034749983643,duration=4586515
travis_fold:end:after_failure.3
travis_fold:start:after_failure.4
travis_time:start:0a875e34
$ 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:04c79d90
travis_time:start:04c79d90
$ 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:1202e6a4
$ 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)

@scottmcm

This comment has been minimized.

Member

scottmcm commented Oct 28, 2018

Thanks for the ccs, but I don't have anything to add 😅 Seems logical to me.

@kennytm

This comment has been minimized.

Member

kennytm commented Oct 28, 2018

r=me after squashing everything down to 1 commit.

cc @rust-lang/libs and @rust-lang/wg-unsafe-code-guidelines in case there's any problems caused by this function.

@CAD97

This comment has been minimized.

Contributor

CAD97 commented Oct 28, 2018

Squashed.

@kennytm

This comment has been minimized.

Member

kennytm commented Oct 28, 2018

@bors r+ rollup

@bors

This comment has been minimized.

Contributor

bors commented Oct 28, 2018

📌 Commit 0757c0f has been approved by kennytm

kennytm added a commit to kennytm/rust that referenced this pull request Oct 28, 2018

Rollup merge of rust-lang#55421 - CAD97:patch-1, r=kennytm
Add ManuallyDrop::take

Tracking issue: rust-lang#55422

Proposed in this form in https://internals.rust-lang.org/t/mini-rfc-manuallydrop-take/8679,
see that thread for some history.

A small convenience wrapper for `ManuallyDrop` that makes a pattern (taking ownership of the contained data in drop) more obvious.

bors added a commit that referenced this pull request Oct 28, 2018

Auto merge of #55433 - kennytm:rollup, r=kennytm
Rollup of 11 pull requests

Successful merges:

 - #55148 (Implement FromStr for PathBuf)
 - #55185 (path suggestions in Rust 2018 should point out the change in semantics)
 - #55191 (Fix sub-variant doc display)
 - #55199 (Impl items have generics)
 - #55244 (Don't rerun MIR passes when inlining)
 - #55252 (Add MaybeUninit::new)
 - #55257 (Allow extern statics with an extern type)
 - #55389 (Remove unnecessary mut in iterator.find_map documentation example, R…)
 - #55406 (Update string.rs)
 - #55412 (Fix an ICE in the min_const_fn analysis)
 - #55421 (Add ManuallyDrop::take)
@SimonSapin

This comment has been minimized.

Contributor

SimonSapin commented Oct 28, 2018

I expected the definition to be ptr::read(&mut slot.value). Reading a ManuallyDrop then unpacking it seems unnecessarily convoluted (even though it probably compiles to the same).

@bors bors merged commit 0757c0f into rust-lang:master Oct 28, 2018

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details

@CAD97 CAD97 deleted the CAD97:patch-1 branch Oct 29, 2018

@scottmcm

This comment has been minimized.

Member

scottmcm commented Nov 1, 2018

@SimonSapin I think it ended up this way because the code snippit on IRLO that became this was written as an external function. The alternative implementation sounds good too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment