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

Require that const param tys implement ConstParamTy #111670

Merged
merged 5 commits into from
Jun 2, 2023

Conversation

compiler-errors
Copy link
Member

  1. Require that const param tys implement ConstParamTy instead of using search_for_adt_const_param_violation
  2. Add StructuralPartialEq as a supertrait for ConstParamTy, since we need to make sure that we derive both PartialEq and Eq
  3. Implement ConstParamTy for tuples up to 12 (or whatever the default for tuples is)
  4. Add some custom diagnostics to ConstParamTy errors, to avoid regressions from (1.). It's still not as great as it could be -- will point out inline in comments.

r? @BoxyUwU

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. 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 May 17, 2023
@rustbot
Copy link
Collaborator

rustbot commented May 17, 2023

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

tests/ui/const-generics/issues/issue-99641.rs Show resolved Hide resolved
@@ -8,10 +8,10 @@ struct CompileTimeSettings{
}

struct Foo<const T: CompileTimeSettings>;
//~^ ERROR using function pointers as const generic parameters is forbidden
//~^ ERROR `CompileTimeSettings` must be annotated with `#[derive(ConstParamTy)]` to be used as the type of a const generic parameter
Copy link
Member Author

Choose a reason for hiding this comment

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

This is an example of the fixme I left above:

// We should probably see if we're allowed to derive ConstParamTy on the type...

Since the user will follow the advice from the error message, then see an error message that &'static [fn()] is a bad field.

@rust-log-analyzer

This comment has been minimized.

@bors
Copy link
Contributor

bors commented May 17, 2023

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

library/core/src/marker.rs Outdated Show resolved Hide resolved
@rust-cloud-vms rust-cloud-vms bot force-pushed the const-param-ty branch 2 times, most recently from 8a9cb03 to 57f7198 Compare May 17, 2023 19:00
@rust-log-analyzer

This comment has been minimized.

juntyr added a commit to juntyr/rust that referenced this pull request May 18, 2023
@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request May 19, 2023
…r=Nilstrieb

Fix doc comment for `ConstParamTy` derive

See rust-lang#111670 (comment)

Thanks `@Nilstrieb` for the pointer :)
GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this pull request May 19, 2023
…r=Nilstrieb

Fix doc comment for `ConstParamTy` derive

See rust-lang#111670 (comment)

Thanks ``@Nilstrieb`` for the pointer :)
GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this pull request May 19, 2023
…r=Nilstrieb

Fix doc comment for `ConstParamTy` derive

See rust-lang#111670 (comment)

Thanks ```@Nilstrieb``` for the pointer :)
@rust-cloud-vms rust-cloud-vms bot force-pushed the const-param-ty branch 3 times, most recently from 98bb09f to ba2a598 Compare May 19, 2023 22:11
@rust-log-analyzer

This comment has been minimized.

Dylan-DPC added a commit to Dylan-DPC/rust that referenced this pull request May 20, 2023
…r=Nilstrieb

Fix doc comment for `ConstParamTy` derive

See rust-lang#111670 (comment)

Thanks ````@Nilstrieb```` for the pointer :)
@rust-log-analyzer

This comment has been minimized.

@bors
Copy link
Contributor

bors commented May 23, 2023

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

@bors bors added the S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. label May 31, 2023
@bors
Copy link
Contributor

bors commented Jun 1, 2023

⌛ Testing commit 6aa1a3538743bd63d04813d8ea29dda6253b06ad with merge 72916f6114413f1ba881c8080c3757b5a0b012a2...

@bors
Copy link
Contributor

bors commented Jun 1, 2023

💔 Test failed - checks-actions

@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 Jun 1, 2023
@rust-log-analyzer

This comment has been minimized.

@BoxyUwU BoxyUwU 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-review Status: Awaiting review from the assignee but also interested parties. labels Jun 1, 2023
@BoxyUwU
Copy link
Member

BoxyUwU commented Jun 1, 2023

bootstrap started using the newest beta which has waffle's PR to add compiler checks to ConstParamTy, which means that when we build std using beta it errors on the (): ConstParamTy impl, you'll have to cfg(bootstrap) those impls. The only reason this didnt show in CI is because bootstrap bumped beta after the r+ 🙃

@compiler-errors
Copy link
Member Author

I #[cfg(not(bootstrap))]'d the impls, seems to bootstrap stages 0 and 1 fine now

@bors r=BoxyUwU

@bors
Copy link
Contributor

bors commented Jun 1, 2023

📌 Commit 97bacba has been approved by BoxyUwU

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-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jun 1, 2023
bors added a commit to rust-lang-ci/rust that referenced this pull request Jun 2, 2023
…mpiler-errors

Rollup of 7 pull requests

Successful merges:

 - rust-lang#111670 (Require that const param tys implement `ConstParamTy`)
 - rust-lang#111914 (CFI: Fix cfi with async: transform_ty: unexpected GeneratorWitness(Bi…)
 - rust-lang#112030 (Migrate `item_trait_alias` to Askama)
 - rust-lang#112150 (Support 128-bit atomics on all x86_64 Apple targets)
 - rust-lang#112174 (Fix broken link)
 - rust-lang#112190 (Improve comments on `TyCtxt` and `GlobalCtxt`.)
 - rust-lang#112193 (Check tuple elements are `Sized` in `offset_of`)

Failed merges:

 - rust-lang#112071 (Group rfcs tests)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 24404e6 into rust-lang:master Jun 2, 2023
@rustbot rustbot added this to the 1.72.0 milestone Jun 2, 2023
flip1995 pushed a commit to flip1995/rust that referenced this pull request Jun 30, 2023
…mpiler-errors

Rollup of 7 pull requests

Successful merges:

 - rust-lang#111670 (Require that const param tys implement `ConstParamTy`)
 - rust-lang#111914 (CFI: Fix cfi with async: transform_ty: unexpected GeneratorWitness(Bi…)
 - rust-lang#112030 (Migrate `item_trait_alias` to Askama)
 - rust-lang#112150 (Support 128-bit atomics on all x86_64 Apple targets)
 - rust-lang#112174 (Fix broken link)
 - rust-lang#112190 (Improve comments on `TyCtxt` and `GlobalCtxt`.)
 - rust-lang#112193 (Check tuple elements are `Sized` in `offset_of`)

Failed merges:

 - rust-lang#112071 (Group rfcs tests)

r? `@ghost`
`@rustbot` modify labels: rollup
thomcc pushed a commit to tcdi/postgrestd that referenced this pull request Jul 18, 2023
thomcc pushed a commit to tcdi/postgrestd that referenced this pull request Jul 18, 2023
Fix doc comment for `ConstParamTy` derive

See rust-lang/rust#111670 (comment)

Thanks ````@Nilstrieb```` for the pointer :)
@compiler-errors compiler-errors deleted the const-param-ty branch August 11, 2023 19:57
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.

7 participants