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 some Ordering methods const #75463

Merged
merged 4 commits into from
Aug 31, 2020
Merged

Make some Ordering methods const #75463

merged 4 commits into from
Aug 31, 2020

Conversation

CDirkx
Copy link
Contributor

@CDirkx CDirkx commented Aug 12, 2020

Constify the following methods of core::cmp::Ordering:

  • reverse
  • then

Possible because of #49146 (Allow if and match in constants).

Tracking issue: #76113

Constify the following methods of `core::cmp::Ordering`:
 - `reverse`
 - `then`

Possible because of rust-lang#49146 (Allow `if` and `match` in constants).
@CDirkx
Copy link
Contributor Author

CDirkx commented Aug 12, 2020

What are the requirements for making functions const_stable or const_unstable?
Would this change require a const_ordering feature gate?

@crlf0710
Copy link
Member

@CDirkx Ping from triage, this needs to get the CI green before review. You'll need to use the #[rustc_const_unstable] attribute. Search within the code, and follow the existing examples will be enough.

@crlf0710 crlf0710 added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. 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-review Status: Awaiting review from the assignee but also interested parties. labels Aug 28, 2020
@crlf0710 crlf0710 requested a review from sfackler August 28, 2020 17:55
@ecstatic-morse
Copy link
Contributor

There's no need for these to be unstable IMO now that if and match are stable in a const fn. It's not like these impls are going to change.

@CDirkx
Copy link
Contributor Author

CDirkx commented Aug 30, 2020

Yeah that is my question, is it enough that #49146 is stabilized to make these methods const_stable, since they are only simple matches? If so, that would also apply to a lot of the methods under const_option (#67441) and const_result ( #67520), as well as some integer methods I believe. I would be happy to make some stabilization PRs for those if that's the descision.

@ecstatic-morse
Copy link
Contributor

ecstatic-morse commented Aug 30, 2020

As I understand it, you're correct and all those methods are eligible for stabilization. (cc @rust-lang/wg-const-eval in case there's an objection). I'll check in with t-libs as well.

In the meantime, I'll happily sign off on the insta-stable version. I guess you just keep the current feature name even though it never did anything?

r? @ecstatic-morse

@ecstatic-morse
Copy link
Contributor

@bors delegate+

r=me with correct release number (1.46 came out this week).

@bors
Copy link
Contributor

bors commented Aug 30, 2020

✌️ @CDirkx can now approve this pull request

`const_ordering` will stabilize in version 1.48.0
@CDirkx
Copy link
Contributor Author

CDirkx commented Aug 30, 2020

@bors r+

@bors
Copy link
Contributor

bors commented Aug 30, 2020

📌 Commit 12f4624 has been approved by CDirkx

@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-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Aug 30, 2020
Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this pull request Aug 31, 2020
Make some Ordering methods const

Constify the following methods of `core::cmp::Ordering`:
 - `reverse`
 - `then`

Possible because of rust-lang#49146 (Allow `if` and `match` in constants).

Tracking issue:  rust-lang#76113
@bors
Copy link
Contributor

bors commented Aug 31, 2020

⌛ Testing commit 12f4624 with merge 92290d1...

@bors
Copy link
Contributor

bors commented Aug 31, 2020

☀️ Test successful - checks-actions, checks-azure
Approved by: CDirkx
Pushing 92290d1 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Aug 31, 2020
@bors bors merged commit 92290d1 into rust-lang:master Aug 31, 2020
@CDirkx CDirkx deleted the ordering-const branch August 31, 2020 03:37
@tesuji
Copy link
Contributor

tesuji commented Aug 31, 2020

@rustbot modify labels: T-libs

@rustbot
Copy link
Collaborator

rustbot commented Aug 31, 2020

Error: Label relnotes can only be set by Rust team members

Please let @rust-lang/release know if you're having trouble with this bot.

@rustbot rustbot added the T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. label Aug 31, 2020
@RalfJung
Copy link
Member

RalfJung commented Aug 31, 2020

Eh, shouldn't there be t-libs FCP on this? I don't think there is precedent for insta-stabilizing new const, but the methods seem simple enough. Still, this needs team approval.

Cc @rust-lang/libs

Also @CDirkx, please don't r+ unless you are the reviewer. When you approve in the name of someone else, please do r=<name of reviewer>. (We use r=me as a short-hand to say exactly that, but it is entire incomprehensible unless you already know what it means.^^)

@RalfJung RalfJung added the relnotes Marks issues that should be documented in the release notes of the next release. label Aug 31, 2020
@jyn514 jyn514 added the A-const-fn Area: const fn foo(..) {..}. Pure functions which can be applied at compile time. label Aug 31, 2020
@CDirkx
Copy link
Contributor Author

CDirkx commented Aug 31, 2020

@RalfJung Ah, yeah I was unsure if that was the intention. Thanks!

@Dylan-DPC-zz Dylan-DPC-zz added this to the 1.48 milestone Aug 31, 2020
ecstatic-morse added a commit to ecstatic-morse/rust that referenced this pull request Aug 31, 2020
This was approved by me prematurely. It needs T-libs approval.
tmandry added a commit to tmandry/rust that referenced this pull request Sep 1, 2020
…Jung

Revert rust-lang#75463

This was approved by me prematurely. It needs T-libs approval. Sorry @CDirkx.

r? @RalfJung
@CDirkx CDirkx restored the ordering-const branch September 1, 2020 02:22
@CDirkx CDirkx deleted the ordering-const branch September 1, 2020 02:24
bors added a commit to rust-lang-ci/rust that referenced this pull request Sep 1, 2020
Rollup of 12 pull requests

Successful merges:

 - rust-lang#75945 (Use `env::func()`, not 'the function env::func' in docs for std::env)
 - rust-lang#76002 (Fix `-Z instrument-coverage` on MSVC)
 - rust-lang#76003 (Adds two source span utility functions used in source-based coverage)
 - rust-lang#76059 (Clean up E0764)
 - rust-lang#76103 (Clean up E0769)
 - rust-lang#76139 (Make `cow_is_borrowed` methods const)
 - rust-lang#76154 (Fix rustdoc strings indentation)
 - rust-lang#76161 (Remove notrust in rustc_middle)
 - rust-lang#76163 (README: Adjust Linux and macOS support platform and architecture)
 - rust-lang#76166 (Make `StringReader` private)
 - rust-lang#76172 (Revert rust-lang#75463)
 - rust-lang#76178 (Update expect-test to 1.0)

Failed merges:

r? @ghost
@RalfJung RalfJung removed the relnotes Marks issues that should be documented in the release notes of the next release. label Sep 1, 2020
@RalfJung RalfJung removed this from the 1.48 milestone Sep 1, 2020
Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this pull request Sep 15, 2020
Make some Ordering methods const

Resubmission of [PR#75463](rust-lang#75463) as per [PR#76172](rust-lang#76172).

Constify the following methods of `core::cmp::Ordering`:
 - `reverse`
 - `then`

Insta-stabilizes these methods as const under the `const_ordering` feature, as their implementation is a trivial match and the recent stabilization of rust-lang#49146 (Allow `if` and `match` in constants).
Note: the `const_ordering` feature has never actually been used as these methods have not been `#[rustc_const_unstable]`.

Tracking issue:  rust-lang#76113
RalfJung added a commit to RalfJung/rust that referenced this pull request Sep 19, 2020
Stabilize some Option methods as const

Stabilize the following methods of `Option` as const:
 - `is_some`
 - `is_none`
 - `as_ref`

These methods are currently const under the unstable feature `const_option` (tracking issue: rust-lang#67441).
I believe these methods to be eligible for stabilization because of the stabilization of rust-lang#49146 (Allow if and match in constants) and the trivial implementations, see also:  [PR#75463](rust-lang#75463).

Related: rust-lang#76225
bors added a commit to rust-lang-ci/rust that referenced this pull request Sep 20, 2020
Stabilize some Result methods as const

Stabilize the following methods of Result as const:
 - `is_ok`
 - `is_err`
 - `as_ref`

A test is also included, analogous to the test for `const_option`.

These methods are currently const under the unstable feature `const_result` (tracking issue: rust-lang#67520).
I believe these methods to be eligible for stabilization because of the stabilization of rust-lang#49146 (Allow if and match in constants) and the trivial implementations, see also: [PR#75463](rust-lang#75463) and [PR#76135](rust-lang#76135).

Note: these methods are the only methods currently under the `const_result` feature, thus this PR results in the removal of the feature.

Related: rust-lang#76225
RalfJung added a commit to RalfJung/rust that referenced this pull request Sep 21, 2020
Stabilize some Option methods as const

Stabilize the following methods of `Option` as const:
 - `is_some`
 - `is_none`
 - `as_ref`

These methods are currently const under the unstable feature `const_option` (tracking issue: rust-lang#67441).
I believe these methods to be eligible for stabilization because of the stabilization of rust-lang#49146 (Allow if and match in constants) and the trivial implementations, see also:  [PR#75463](rust-lang#75463).

Related: rust-lang#76225
ebroto pushed a commit to ebroto/rust-clippy that referenced this pull request Sep 21, 2020
Stabilize some Result methods as const

Stabilize the following methods of Result as const:
 - `is_ok`
 - `is_err`
 - `as_ref`

A test is also included, analogous to the test for `const_option`.

These methods are currently const under the unstable feature `const_result` (tracking issue: #67520).
I believe these methods to be eligible for stabilization because of the stabilization of #49146 (Allow if and match in constants) and the trivial implementations, see also: [PR#75463](rust-lang/rust#75463) and [PR#76135](rust-lang/rust#76135).

Note: these methods are the only methods currently under the `const_result` feature, thus this PR results in the removal of the feature.

Related: #76225
@cuviper cuviper added this to the 1.48.0 milestone May 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-const-fn Area: const fn foo(..) {..}. Pure functions which can be applied at compile time. merged-by-bors This PR was explicitly merged by bors. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants