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

Change ManuallyDrop<T> to a lang item. #52711

Merged
merged 4 commits into from
Jul 28, 2018

Conversation

eddyb
Copy link
Member

@eddyb eddyb commented Jul 25, 2018

This PR implements the approach @RalfJung proposes in https://internals.rust-lang.org/t/pre-rfc-unions-drop-types-and-manuallydrop/8025 (lang item struct instead of union).

A followup PR can easily solve #47034 as well, by just adding a few ?Sized to libcore/mem.rs.

r? @nikomatsakis

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jul 25, 2018
@nagisa nagisa added the relnotes Marks issues that should be documented in the release notes of the next release. label Jul 25, 2018
@RalfJung

This comment has been minimized.

@rust-highfive
Copy link
Collaborator

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.
[01:15:50] travis_fold:end:stage0-linkchecker

[01:15:50] travis_time:end:stage0-linkchecker:start=1532547690616675272,finish=1532547693142869704,duration=2526194432

[01:16:03] reference/destructors.html:217: broken link - std/mem/union.ManuallyDrop.html
[01:16:03] reference/print.html:6644: broken link - std/mem/union.ManuallyDrop.html
[01:16:05] thread 'main' panicked at 'found some broken links', tools/linkchecker/main.rs:49:9
[01:16:05] 
[01:16:05] 
[01:16:05] command did not execute successfully: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-tools-bin/linkchecker" "/checkout/obj/build/x86_64-unknown-linux-gnu/doc"
[01:16:05] expected success, got: exit code: 101
[01:16:05] expected success, got: exit code: 101
[01:16:05] 
[01:16:05] 
[01:16:05] failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test
[01:16:05] Build completed unsuccessfully in 0:30:50
[01:16:05] Makefile:58: recipe for target 'check' failed
[01:16:05] make: *** [check] Error 1

The command "stamp sh -x -c "$RUN_SCRIPT"" exited with 2.
travis_time:start:0e0645c0
$ date && (curl -fs --head https://google.com | grep ^Date: | sed 's/Date: //g' || true)
---
travis_time:end:3377eb80:start=1532547710293822346,finish=1532547710303072311,duration=9249965
travis_fold:end:after_failure.3
travis_fold:start:after_failure.4
travis_time:start:01cea5d2
$ 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 -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:32dd27d6
travis_time:start:32dd27d6
$ 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:0e595516
$ 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)

@Centril Centril added the T-lang Relevant to the language team, which will review and decide on the PR/issue. label Jul 25, 2018
#[derive(Copy)]
pub union ManuallyDrop<T>{ value: T }
#[lang = "manually_drop"]
#[derive(Copy, Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice that these can all just be derives, now! 👍

@eddyb eddyb changed the title Change ManuallySized<T> to a lang item and relax it to allow T: ?Sized. Change ManuallyDrop<T> to a lang item and relax it to allow T: ?Sized. Jul 25, 2018
@nikomatsakis
Copy link
Contributor

@eddyb

[01:16:03] reference/destructors.html:217: broken link - std/mem/union.ManuallyDrop.html
[01:16:03] reference/print.html:6644: broken link - std/mem/union.ManuallyDrop.html

r=me once travis is happy

@@ -243,7 +243,10 @@ pub fn trivial_dropck_outlives<'tcx>(tcx: TyCtxt<'_, '_, 'tcx>, ty: Ty<'tcx>) ->

ty::TyAdt(def, _) => {
if def.is_union() {
// Unions never run have a dtor.
// Unions never have a dtor.
true
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A union implementing Drop itself is not a concern here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good question, cc @arielb1 @pnkfelix @nikomatsakis

Copy link
Member

@RalfJung RalfJung Jul 27, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, yes, I think it is a concern. :D #52786
(but the bug is already on nightly, so it's not introduced by this PR)

@RalfJung
Copy link
Member

This makes ManuallyDrop for unsized types insta-stable. Does that require an FCP?

@eddyb said he doesn't have much time to follow up on this, but I think I can take over. I should probably also add at least one test because it seems there are none?

@eddyb
Copy link
Member Author

eddyb commented Jul 27, 2018

FWIW we would only need an FCP for the second commit, the first one can be landed independently and then union-related changes can be made in parallel with generalized to !Sized.

@RalfJung
Copy link
Member

So shall we split the PR?

@eddyb eddyb changed the title Change ManuallyDrop<T> to a lang item and relax it to allow T: ?Sized. Change ManuallyDrop<T> to a lang item. Jul 27, 2018
@RalfJung
Copy link
Member

PR submitted to fix link in reference: rust-lang/reference#373

@rust-highfive
Copy link
Collaborator

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.

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)

@RalfJung
Copy link
Member

@TimNN Bot shows empty log.

@RalfJung
Copy link
Member

Updated reference submodule so the links should be fixed.

@rust-highfive
Copy link
Collaborator

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.
[01:12:44] travis_fold:end:stage0-linkchecker

[01:12:44] travis_time:end:stage0-linkchecker:start=1532696023062930756,finish=1532696025506231937,duration=2443301181

[01:12:56] reference/items/implementations.html:268: broken link fragment `#lint-check-attributes.html` pointing to `reference/attributes.html`
[01:12:56] reference/expressions/block-expr.html:205: broken link fragment `#lint-check-attributes.html` pointing to `reference/attributes.html`
[01:12:56] reference/print.html:2292: broken link fragment `#lint-check-attributes.html` pointing to `reference/attributes.html`
[01:12:56] reference/print.html:3485: broken link fragment `#lint-check-attributes.html` pointing to `reference/attributes.html`
[01:12:56] reference/print.html:3845: broken link fragment `#lint-check-attributes.html` pointing to `reference/attributes.html`
[01:12:56] reference/statements.html:227: broken link fragment `#lint-check-attributes.html` pointing to `reference/attributes.html`
[01:12:58] thread 'main' panicked at 'found some broken links', tools/linkchecker/main.rs:49:9
[01:12:58] 
[01:12:58] 
[01:12:58] command did not execute successfully: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-tools-bin/linkchecker" "/checkout/obj/build/x86_64-unknown-linux-gnu/doc"
[01:12:58] expected success, got: exit code: 101
[01:12:58] expected success, got: exit code: 101
[01:12:58] 
[01:12:58] 
[01:12:58] failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test
[01:12:58] Build completed unsuccessfully in 0:30:31
[01:12:58] make: *** [check] Error 1
[01:12:58] Makefile:58: recipe for target 'check' failed

The command "stamp sh -x -c "$RUN_SCRIPT"" exited with 2.
travis_time:start:15946a16
$ date && (curl -fs --head https://google.com | grep ^Date: | sed 's/Date: //g' || true)
---
travis_time:end:03414e70:start=1532696041014582096,finish=1532696041023499098,duration=8917002
travis_fold:end:after_failure.3
travis_fold:start:after_failure.4
travis_time:start:0cac76c6
$ 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 -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:2f984988
travis_time:start:2f984988
$ 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:03449c0e
$ 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)

@RalfJung
Copy link
Member

RalfJung commented Jul 27, 2018

Dang, unrelated updates in the reference contain broken links.

Reported as rust-lang/reference#374

EDIT: Fix submitted: rust-lang/reference#375

@RalfJung
Copy link
Member

r=me once travis is happy

@bors r=nikomatsakis

@bors
Copy link
Contributor

bors commented Jul 27, 2018

📌 Commit 4e6aea1 has been approved by nikomatsakis

@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 Jul 27, 2018
@bors
Copy link
Contributor

bors commented Jul 28, 2018

⌛ Testing commit 4e6aea1 with merge 26e73da...

bors added a commit that referenced this pull request Jul 28, 2018
Change ManuallyDrop<T> to a lang item.

This PR implements the approach @RalfJung proposes in https://internals.rust-lang.org/t/pre-rfc-unions-drop-types-and-manuallydrop/8025 (lang item `struct` instead of `union`).

A followup PR can easily solve #47034 as well, by just adding a few `?Sized` to `libcore/mem.rs`.

r? @nikomatsakis
@bors
Copy link
Contributor

bors commented Jul 28, 2018

☀️ Test successful - status-appveyor, status-travis
Approved by: nikomatsakis
Pushing 26e73da to master...

@bors bors merged commit 4e6aea1 into rust-lang:master Jul 28, 2018
@eddyb eddyb deleted the unsized-manuallydrop branch July 28, 2018 19:04
kennytm added a commit to kennytm/rust that referenced this pull request Aug 14, 2018
unsized ManuallyDrop

I think this matches what @eddyb had in rust-lang#52711 originally.

~~However, I have never added a `CoerceUnsized` before so I am not sure if I did this right. I copied the `unstable` attribute on the `impl` from elsewhere, but AFAIK it is useless because `impl`'s are insta-stable... so shouldn't this rather say "stable since 1.30"?~~

This is insta-stable and hence requires FCP, at least.

Fixes rust-lang#47034
bors added a commit that referenced this pull request Aug 14, 2018
unsized ManuallyDrop

I think this matches what @eddyb had in #52711 originally.

~~However, I have never added a `CoerceUnsized` before so I am not sure if I did this right. I copied the `unstable` attribute on the `impl` from elsewhere, but AFAIK it is useless because `impl`'s are insta-stable... so shouldn't this rather say "stable since 1.30"?~~

This is insta-stable and hence requires FCP, at least.

Fixes #47034
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
relnotes Marks issues that should be documented in the release notes of the next release. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-lang Relevant to the language team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants