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

Add the #[derive_const] attribute #102049

Merged
merged 1 commit into from
Nov 12, 2022
Merged

Conversation

fee1-dead
Copy link
Member

@fee1-dead fee1-dead commented Sep 20, 2022

Closes #102371. This is a minimal patchset for the attribute to work. There are no restrictions on what traits this attribute applies to.

r? @oli-obk

@rustbot rustbot added T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Sep 20, 2022
@rustbot
Copy link
Collaborator

rustbot commented Sep 20, 2022

Hey! It looks like you've submitted a new PR for the library teams!

If this PR contains changes to any rust-lang/rust public library APIs then please comment with @rustbot label +T-libs-api -T-libs to tag it appropriately. If this PR contains changes to any unstable APIs please edit the PR description to add a link to the relevant API Change Proposal or create one if you haven't already. If you're unsure where your change falls no worries, just leave it as is and the reviewer will take a look and make a decision to forward on if necessary.

Examples of T-libs-api changes:

  • Stabilizing library features
  • Introducing insta-stable changes such as new implementations of existing stable traits on existing stable types
  • Introducing new or changing existing unstable library APIs (excluding permanently unstable features / features without a tracking issue)
  • Changing public documentation in ways that create new stability guarantees
  • Changing observable runtime behavior of library APIs

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Sep 20, 2022
@onestacked
Copy link
Contributor

onestacked commented Sep 22, 2022

Do the PartialOrd and friends implementations work for enums?
If they do maybe add a test for them.

Also can this be used in std, since it doesn't have feature gates?

@fee1-dead fee1-dead changed the title [WIP] Add the #[derive_const] attribute Add the #[derive_const] attribute Sep 30, 2022
@oli-obk
Copy link
Contributor

oli-obk commented Nov 8, 2022

@bors r+

@bors
Copy link
Contributor

bors commented Nov 8, 2022

📌 Commit a052f2c has been approved by oli-obk

It is now in the queue for this repository.

@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 Nov 8, 2022
Manishearth added a commit to Manishearth/rust that referenced this pull request Nov 11, 2022
…oli-obk

Add the `#[derive_const]` attribute

Closes rust-lang#102371. This is a minimal patchset for the attribute to work. There are no restrictions on what traits this attribute applies to.

r? ``@oli-obk``
Manishearth added a commit to Manishearth/rust that referenced this pull request Nov 11, 2022
…oli-obk

Add the `#[derive_const]` attribute

Closes rust-lang#102371. This is a minimal patchset for the attribute to work. There are no restrictions on what traits this attribute applies to.

r? ```@oli-obk```
Manishearth added a commit to Manishearth/rust that referenced this pull request Nov 11, 2022
…oli-obk

Add the `#[derive_const]` attribute

Closes rust-lang#102371. This is a minimal patchset for the attribute to work. There are no restrictions on what traits this attribute applies to.

r? ````@oli-obk````
bors added a commit to rust-lang-ci/rust that referenced this pull request Nov 12, 2022
Rollup of 7 pull requests

Successful merges:

 - rust-lang#102049 (Add the `#[derive_const]` attribute)
 - rust-lang#103970 (Unhide unknown spans)
 - rust-lang#104206 (Remove `save_and_restore_in_snapshot_flag`, use `ObligationCtxt` more)
 - rust-lang#104214 (Emit error in `collecting_trait_impl_trait_tys` on mismatched signatures)
 - rust-lang#104267 (rustdoc: use checkbox instead of switch for settings toggles)
 - rust-lang#104302 (Update cargo)
 - rust-lang#104303 (UI tests can be assigned to T-compiler)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 4b0b898 into rust-lang:master Nov 12, 2022
@rustbot rustbot added this to the 1.67.0 milestone Nov 12, 2022
@yanchith
Copy link
Contributor

yanchith commented Feb 4, 2023

I wonder if there's a plan for const traits to be derived by regular derives, if eligible. Having to have both a regular derive and derive_const is quite noisy.

There's already a bit of precendence for smarter derives with generics, where the derive outputs a where clause, e.g. for Clone. Could it do something analogous for const traits?

I know this could be some kind of a semver footgun for libraries, but those could fall back to manual impls, if they really want to be sure not to overpromise.

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. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Should we keep un-deriving traits in library to make them const?
9 participants