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

Make Unique::as_ptr, NonNull::dangling and NonNull::cast const #58750

Merged
merged 2 commits into from
Mar 9, 2019
Merged

Make Unique::as_ptr, NonNull::dangling and NonNull::cast const #58750

merged 2 commits into from
Mar 9, 2019

Conversation

TimDiekmann
Copy link
Member

No description provided.

@rust-highfive
Copy link
Collaborator

r? @Kimundi

(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 Feb 26, 2019
@oli-obk
Copy link
Contributor

oli-obk commented Feb 26, 2019

Please add some tests using these in a const context. Also consider making them rustc_const_unstable so the constness isn't insta-stable

@TimDiekmann
Copy link
Member Author

TimDiekmann commented Feb 26, 2019

Should rustc_const_unstable also apply on Unique as it's not pub unstable?

r? @oli-obk

@rust-highfive rust-highfive assigned oli-obk and unassigned Kimundi Feb 26, 2019
@oli-obk
Copy link
Contributor

oli-obk commented Feb 26, 2019

Since it's unstable, there's no need

@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:01f4ae1b:start=1551179575121358287,finish=1551179578001919871,duration=2880561584
$ 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 IMAGE=x86_64-gnu-llvm-6.0
---

[00:03:37] travis_fold:start:tidy
travis_time:start:tidy
tidy check
[00:03:37] tidy error: /checkout/src/libcore/ptr.rs:2905: trailing whitespace
[00:03:37] tidy error: /checkout/src/test/ui/consts/const-ptr-nonnull.rs:4: line longer than 100 chars
[00:03:37] tidy error: /checkout/src/test/ui/consts/const-ptr-nonnull.rs:5: trailing whitespace
[00:03:37] tidy error: /checkout/src/test/ui/consts/const-ptr-nonnull.rs:8: line longer than 100 chars
[00:03:37] tidy error: /checkout/src/test/ui/consts/const-ptr-unique.rs:8: line longer than 100 chars
[00:03:37] tidy error: /checkout/src/test/run-pass/consts/const-ptr-nonnull.rs:17: trailing whitespace
[00:03:38] some tidy checks failed
[00:03:38] 
[00:03:38] 
[00:03:38] 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:03:38] 
[00:03:38] 
[00:03:38] failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test src/tools/tidy
[00:03:38] Build completed unsuccessfully in 0:00:44
[00:03:38] Build completed unsuccessfully in 0:00:44
[00:03:38] make: *** [tidy] Error 1
[00:03:38] Makefile:68: recipe for target 'tidy' failed
The command "stamp sh -x -c "$RUN_SCRIPT"" exited with 2.
travis_time:start:015d7ce3
$ date && (curl -fs --head https://google.com | grep ^Date: | sed 's/Date: //g' || true)
Tue Feb 26 11:16:47 UTC 2019
---
travis_time:end:1af693c0:start=1551179807939747195,finish=1551179807944240954,duration=4493759
travis_fold:end:after_failure.3
travis_fold:start:after_failure.4
travis_time:start:025d155c
$ 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:013a19e7
travis_time:start:013a19e7
$ 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:0672f22e
$ 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)

src/libcore/ptr.rs Outdated Show resolved Hide resolved
@@ -2790,7 +2790,7 @@ impl<T: ?Sized> Unique<T> {
}

/// Acquires the underlying `*mut` pointer.
pub fn as_ptr(self) -> *mut T {
pub const fn as_ptr(self) -> *mut T {
Copy link
Contributor

Choose a reason for hiding this comment

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

cc @Centril is it too dangerous that just adding a const doesn't require anything like a #[const_stable(since = "1.2.3")] attribute?

Copy link
Contributor

Choose a reason for hiding this comment

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

Dangerous from what perspective? If it's used in a min-const-fn it will also need to be min-const-fn... or do you mean from the POV of accidental stabilization?

Copy link
Contributor

Choose a reason for hiding this comment

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

yes, accidental stabilization. Like making something stable that is already const fn stabilizes the constness along with it.

Copy link
Member Author

Choose a reason for hiding this comment

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

Do you mean any stabilized const fn should have something like a #[const_stable] attribute?

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah... idk if I find it risky rising to the level of dangerous but there's some risk, no doubt. @varkor wanted it from a different perspective (#57562 (comment)) but I thought it too much of an annotation burden. However, from the POV of accidental stabilization, #[const_stable(...)] makes sense to me.

Can you open up an issue and cc me and varkor?

Copy link
Contributor

Choose a reason for hiding this comment

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

@TimDiekmann Yeah, that's the idea.

@oli-obk
Copy link
Contributor

oli-obk commented Feb 26, 2019

@bors r+

@bors
Copy link
Contributor

bors commented Feb 26, 2019

📌 Commit c5f3830 has been approved by oli-obk

@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 Feb 26, 2019
Centril added a commit to Centril/rust that referenced this pull request Feb 27, 2019
Make `Unique::as_ptr`, `NonNull::dangling` and `NonNull::cast` const
Centril added a commit to Centril/rust that referenced this pull request Feb 27, 2019
Make `Unique::as_ptr`, `NonNull::dangling` and `NonNull::cast` const
Centril added a commit to Centril/rust that referenced this pull request Feb 27, 2019
Make `Unique::as_ptr`, `NonNull::dangling` and `NonNull::cast` const
@Centril
Copy link
Contributor

Centril commented Feb 27, 2019

Failed in #58766 (comment), @bors r-

@bors bors added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Feb 27, 2019
Make `Unique::as_ptr` const without feature attribute as it's unstable
Make `NonNull::dangling` and `NonNull::cast` const with `feature = "const_ptr_nonnull"`
@TimDiekmann
Copy link
Member Author

Yes, indeed, very helpful!

@bors
Copy link
Contributor

bors commented Mar 4, 2019

⌛ Testing commit 60a649e with merge 28660c5782de2bb06e1571d5eb9491a7316c4647...

@bors
Copy link
Contributor

bors commented Mar 4, 2019

💔 Test failed - status-appveyor

@bors bors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Mar 4, 2019
@TimDiekmann
Copy link
Member Author

TimDiekmann commented Mar 4, 2019

Command exited with code 259

Seems like a spurious failure as mentioned in #58160.

@ljedrz
Copy link
Contributor

ljedrz commented Mar 4, 2019

@bors retry

@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 4, 2019
@bors
Copy link
Contributor

bors commented Mar 4, 2019

⌛ Testing commit 60a649e with merge 053b2117f7e4b3bbbf1130289882f6772813bea4...

@bors
Copy link
Contributor

bors commented Mar 4, 2019

💔 Test failed - status-appveyor

@bors bors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Mar 4, 2019
@Centril
Copy link
Contributor

Centril commented Mar 5, 2019

@bors retry

@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 5, 2019
Centril added a commit to Centril/rust that referenced this pull request Mar 9, 2019
Make `Unique::as_ptr`, `NonNull::dangling` and `NonNull::cast` const
Centril added a commit to Centril/rust that referenced this pull request Mar 9, 2019
Make `Unique::as_ptr`, `NonNull::dangling` and `NonNull::cast` const
Centril added a commit to Centril/rust that referenced this pull request Mar 9, 2019
Make `Unique::as_ptr`, `NonNull::dangling` and `NonNull::cast` const
bors added a commit that referenced this pull request Mar 9, 2019
Rollup of 13 pull requests

Successful merges:

 - #58518 (Use early unwraps instead of bubbling up errors just to unwrap in the end)
 - #58626 (rustdoc: add option to calculate "documentation coverage")
 - #58629 (rust-lldb: fix crash when printing empty string)
 - #58660 (MaybeUninit: add read_initialized, add examples)
 - #58670 (fixes #52482)
 - #58676 (look for python2 symlinks before bootstrap python)
 - #58679 (Refactor passes and pass execution to be more parallel)
 - #58750 (Make `Unique::as_ptr`, `NonNull::dangling` and `NonNull::cast` const)
 - #58762 (Mention `unwind(aborts)` in diagnostics for `#[unwind]`)
 - #58924 (Add as_slice() to slice::IterMut and vec::Drain)
 - #58990 (Actually publish miri in the manifest)
 - #59018 (std: Delete a by-definition spuriously failing test)
 - #59045 (Expose new_sub_parser_from_file)

Failed merges:

r? @ghost
@bors bors merged commit 60a649e into rust-lang:master Mar 9, 2019
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