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 the getter for NonZero types into a const fn #56739

Closed
wants to merge 6 commits into
base: master
from

Conversation

Projects
None yet
@Lokathor
Copy link

Lokathor commented Dec 12, 2018

I opened an issue for this here earlier today and no one immediately called it foolish, so here's the PR for it.

@rust-highfive

This comment has been minimized.

Copy link
Collaborator

rust-highfive commented Dec 12, 2018

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @kennytm (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.

@oli-obk

This comment has been minimized.

Copy link
Contributor

oli-obk commented Dec 12, 2018

Previous attempt: #54799

The other PR also has a bunch of tests and related changes. If you have some spare time, it would be great if you could just rebase that PR and carry it over the finish line.

@oli-obk oli-obk assigned oli-obk and unassigned kennytm Dec 12, 2018

@Lokathor

This comment has been minimized.

Copy link

Lokathor commented Dec 12, 2018

Wasn't aware of the other PR. I'll attempt that as soon as I can find the time.

@kennytm

This comment has been minimized.

Copy link
Member

kennytm commented Dec 12, 2018

@Lokathor

This comment has been minimized.

Copy link

Lokathor commented Dec 12, 2018

Near as I can tell, several of the changes involved adding a special feature

  • #![feature(const_nonzero_methods)]

which we don't need to bother with now that the minimal const fn is stable for everybody. Does that sound right @oli-obk ? I can get to doing this later today after work.

@oli-obk

This comment has been minimized.

Copy link
Contributor

oli-obk commented Dec 12, 2018

which we don't need to bother with now that the minimal const fn is stable for everybody. Does that sound right @oli-obk ?

We still need to do that. Just like any other feature, we first implement it behind a feature gate, and then, once it has been tested on nightly, we stabilize the feature.

@Lokathor

This comment has been minimized.

Copy link

Lokathor commented Dec 12, 2018

I added the test and gate and such for NonZero types, but I didn't touch DebruijnIndex or any other thing at all. I don't have any understanding of those other parts and I don't want to get lots in the weeds. I'm focusing on a small PR that's a clear improvement, and other things can come later.

@rust-highfive

This comment was marked as outdated.

Copy link
Collaborator

rust-highfive commented Dec 12, 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:2435844f:start=1544653795282699541,finish=1544653935474823732,duration=140192124191
$ 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-5.0
---

[00:03:29] travis_fold:start:tidy
travis_time:start:tidy
tidy check
[00:03:29] tidy error: /checkout/src/test/ui/consts/const-nonzero.rs: missing trailing newline
[00:03:30] some tidy checks failed
[00:03:30] 
[00:03:30] 
[00:03:30] 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:30] 
[00:03:30] 
[00:03:30] failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test src/tools/tidy
[00:03:30] Build completed unsuccessfully in 0:01:01
[00:03:30] Build completed unsuccessfully in 0:01:01
[00:03:30] Makefile:79: recipe for target 'tidy' failed
[00:03:30] make: *** [tidy] Error 1
The command "stamp sh -x -c "$RUN_SCRIPT"" exited with 2.
travis_time:start:15dcf3b3
$ date && (curl -fs --head https://google.com | grep ^Date: | sed 's/Date: //g' || true)
Wed Dec 12 22:35:55 UTC 2018
---
travis_time:end:04cfc58a:start=1544654155749368928,finish=1544654155754251930,duration=4883002
travis_fold:end:after_failure.3
travis_fold:start:after_failure.4
travis_time:start:00db2d32
$ 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:0168e8e0
travis_time:start:0168e8e0
$ 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:00573760
$ 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

This comment has been minimized.

Copy link
Contributor

Centril commented Dec 13, 2018

which we don't need to bother with now that the minimal const fn is stable for everybody. Does that sound right @oli-obk ?

We still need to do that. Just like any other feature, we first implement it behind a feature gate, and then, once it has been tested on nightly, we stabilize the feature.

I think we can dispense with that since we have min_const_fn on stable now; imo someone from T-libs can just FCP instead.

cc @SimonSapin

@SimonSapin

This comment has been minimized.

Copy link
Contributor

SimonSapin commented Dec 13, 2018

I’m in favor of making this constness stable immediately.

@rfcbot fcp merge

@Lokathor

This comment has been minimized.

Copy link

Lokathor commented Dec 13, 2018

Should I do one more commit to remove the #[rustc_const_unstable(feature = "const_nonzero_methods")] then?

@SimonSapin SimonSapin added the T-libs label Dec 13, 2018

@SimonSapin

This comment has been minimized.

Copy link
Contributor

SimonSapin commented Dec 13, 2018

@Lokathor Either that, or force-push your branch to remove the commit that adds it. But maybe only after we get team consensus, in case someone thinks differently.

With the team label:

@rfcbot fcp merge

@rfcbot

This comment has been minimized.

Copy link

rfcbot commented Dec 13, 2018

Team member @SimonSapin has proposed to merge this. The next step is review by the rest of the tagged teams:

No concerns currently listed.

Once a majority of reviewers approve (and none object), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up!

See this document for info about what commands tagged team members can give me.

@alexcrichton

This comment has been minimized.

Copy link
Member

alexcrichton commented Dec 13, 2018

It's not 100% clear to me if checking a box to stabilize this as const or just the idea that it may one day be stable with const, but I'm totally fine merging this as stable const with team consensus

@dtolnay

This comment has been minimized.

Copy link
Member

dtolnay commented Dec 13, 2018

As implemented in the PR, if the constness is unstable why did feature(const_nonzero_methods) need to get added in librustc / librustc_data_structures / librustc_mir? Would those crates not have compiled without feature(const_nonzero_methods) i.e. is this a breaking change? Those crates can't already have been using NonZeroT::get in const context since it wasn't const fn. If they were using NonZeroT::get but not in const context then why does that require enabling feature(const_nonzero_methods)?

@oli-obk

This comment has been minimized.

Copy link
Contributor

oli-obk commented Dec 13, 2018

Would those crates not have compiled without feature(const_nonzero_methods) i.e. is this a breaking change?

This is just a leftover from minimizing #54799, which actually used the function in a const way. I did not comment on that, because it was going to go away anyway if we choose to directly stabilize.

@SimonSapin

This comment has been minimized.

Copy link
Contributor

SimonSapin commented Dec 13, 2018

In #56739 (comment) I proposed FCP to stabilize as const, without a feature gate. If we have team consensus, the PR would need to change before merging.

@bors

This comment has been minimized.

Copy link
Contributor

bors commented Dec 18, 2018

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

@Lokathor

This comment has been minimized.

Copy link

Lokathor commented Dec 18, 2018

The merge conflict is simple to fix but we're waiting on 1 more vote before deciding on instant stable or nightly with feature. I don't want to clutter up the commit list, so I'll wait for that vote and decision.

But thanks bors-bot.

@ZirconiumX

This comment has been minimized.

Copy link

ZirconiumX commented Dec 22, 2018

Ping from not-triage: can @Kimundi, @sfackler or @withoutboats review this? We just need one more tick for a majority.

@rfcbot

This comment has been minimized.

Copy link

rfcbot commented Dec 23, 2018

🔔 This is now entering its final comment period, as per the review above. 🔔

@Lokathor

This comment has been minimized.

Copy link

Lokathor commented Dec 23, 2018

@SimonSapin so it seems like we're going for the instant-stable option, correct?

@oli-obk

This comment has been minimized.

Copy link
Contributor

oli-obk commented Dec 23, 2018

yes, feel free to proactively update the PR if you want

@Lokathor

This comment has been minimized.

Copy link

Lokathor commented Dec 23, 2018

@oli-obk all set.

@Centril Centril added the relnotes label Dec 25, 2018

@bors

This comment has been minimized.

Copy link
Contributor

bors commented Dec 27, 2018

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

@Lokathor

This comment has been minimized.

Copy link

Lokathor commented Dec 27, 2018

@SimonSapin why would you do this to me on the day that my ISP stuffers a national outage! :P

I will rebase when I can.

@Centril

This comment has been minimized.

Copy link
Contributor

Centril commented Dec 28, 2018

@Lokathor did the rebase go wrong?

@Lokathor

This comment has been minimized.

Copy link

Lokathor commented Dec 28, 2018

It said there was nothing to rebase? Maybe I typed in the git command wrong. The "resolve conflicts" tool seems to have sorted it out though.

@Centril

This comment has been minimized.

Copy link
Contributor

Centril commented Dec 28, 2018

@Lokathor You have a merge-commit tho and we prefer not to have those... ;)

@SimonSapin

This comment has been minimized.

Copy link
Contributor

SimonSapin commented Dec 28, 2018

Ehh sorry? I can take care of rebasing for you if you’d like. Let me know, and make sure you check the checkbox https://help.github.com/articles/allowing-changes-to-a-pull-request-branch-created-from-a-fork/#enabling-repository-maintainer-permissions-on-existing-pull-requests

@Dylan-DPC

This comment has been minimized.

Copy link
Member

Dylan-DPC commented Dec 28, 2018

Reworked this in #57167

@Dylan-DPC Dylan-DPC closed this Dec 28, 2018

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

Auto merge of #57167 - Dylan-DPC:feature/non-zero-getters, r=SimonSapin
Make the getter for NonZero types into a const fn

Closes #53331

Rework of #56739

cc @Lokathor

r? @oli-obk
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment