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

Coerce const FnDefs to implement const Fn traits #88963

Merged
merged 2 commits into from
Oct 2, 2021

Conversation

fee1-dead
Copy link
Member

You can now pass a FnDef to a function expecting F where F: ~const FnTrait.

r? @oli-obk

@rustbot label T-compiler F-const_trait_impl

@rust-highfive
Copy link
Collaborator

Some changes occurred in src/tools/clippy.

cc @rust-lang/clippy

@rustbot rustbot added F-const_trait_impl `#![feature(const_trait_impl)]` T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Sep 15, 2021
@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Sep 15, 2021
@rust-log-analyzer

This comment has been minimized.

@fee1-dead
Copy link
Member Author

@oli-obk Can we nominate this and #88558 for beta backport? It is necessary for me to go on and actually make it possible for Iterator to have const impls.

@oli-obk
Copy link
Contributor

oli-obk commented Sep 15, 2021

Can we nominate this and #88558 for beta backport?

that's not really something we do beta backports for.

Why do you need a bootstrap compiler with this? There is no syntactical component here, afaict you can use cfg(bootstrap)?

@fee1-dead
Copy link
Member Author

fee1-dead commented Sep 15, 2021

That is true, but does cfg work on bounds? Some trait functions require things like:
where Self::Item: ~const Drop which means I need to duplicate the documentation just for adding a trivial ~const Drop bound.

Or is it fine to have no documentation for the cfg(bootstrap) function?

@oli-obk
Copy link
Contributor

oli-obk commented Sep 15, 2021

I don't think it works on bounds, but you also don't need to duplicate the docs. The bootstrap version is a copy of the original function with dummy docs, while the original function gets the new attribute and a not(bootstrap) cfg

@fee1-dead
Copy link
Member Author

I still want the "const Drop" mega PR to be backported. It allows ~const bounds on assoc fns on inherent impls. That is an AST change which should be backported. Maybe we could cherry pick the commit? f749e05

@oli-obk
Copy link
Contributor

oli-obk commented Sep 15, 2021

oh, I didn't know the ast validator ran on cfged out code.

Still, even if I nominate this (which I'm not sure I want to), it's likely going to get rejected by the compiler team as "not critical for beta". We only backport bugfixes, nothing else. This would be a new kind of backport, so it would probably need an MCP and all. Better to just let it ride the trains and work without libcore/libstd right now.

@fee1-dead
Copy link
Member Author

fee1-dead commented Sep 15, 2021

EDITED: It is probably not suitable for beta backport, the process doesn't favor changes backported to beta, for that purpose:

  1. some days before the next stable release, we bump the stable version, the current beta branch gets merged into stable, and the master branch gets merged into beta.
  2. Then we make a beta release, and bump the bootstrap compiler of master to that beta release.

It is a simplified procedure, there are more to be done, but it doesn't help with AST changes. If those changes are backported into beta, it just means that it appears in the next stable release. It doesn't interact with the bootstrap compiler.

@oli-obk oli-obk mentioned this pull request Sep 16, 2021
3 tasks
@bjorn3
Copy link
Member

bjorn3 commented Sep 16, 2021

You can use a macro to hide code from the ast validator.

@oli-obk
Copy link
Contributor

oli-obk commented Sep 28, 2021

@bors r+

@bors
Copy link
Contributor

bors commented Sep 28, 2021

📌 Commit f8aa73d 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 Sep 28, 2021
fee1-dead added a commit to fee1-dead-contrib/rust that referenced this pull request Oct 1, 2021
Coerce const FnDefs to implement const Fn traits

You can now pass a FnDef to a function expecting `F` where `F: ~const FnTrait`.

r? `@oli-obk`

`@rustbot` label T-compiler F-const_trait_impl
bors added a commit to rust-lang-ci/rust that referenced this pull request Oct 1, 2021
…arth

Rollup of 7 pull requests

Successful merges:

 - rust-lang#85223 (rustdoc: Clarified the attribute which prompts the warning)
 - rust-lang#88847 (platform-support.md: correct ARMv7+MUSL platform triple notes)
 - rust-lang#88963 (Coerce const FnDefs to implement const Fn traits )
 - rust-lang#89376 (Fix use after drop in self-profile with llvm events)
 - rust-lang#89422 (Replace whitespaces in doctests' name with dashes)
 - rust-lang#89440 (Clarify a sentence in the documentation of Vec (rust-lang#84488))
 - rust-lang#89441 (Normalize after substituting via `field.ty()`)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 743e842 into rust-lang:master Oct 2, 2021
@rustbot rustbot added this to the 1.57.0 milestone Oct 2, 2021
flip1995 pushed a commit to flip1995/rust that referenced this pull request Oct 7, 2021
Coerce const FnDefs to implement const Fn traits

You can now pass a FnDef to a function expecting `F` where `F: ~const FnTrait`.

r? ``@oli-obk``

``@rustbot`` label T-compiler F-const_trait_impl
flip1995 pushed a commit to flip1995/rust that referenced this pull request Oct 7, 2021
…arth

Rollup of 7 pull requests

Successful merges:

 - rust-lang#85223 (rustdoc: Clarified the attribute which prompts the warning)
 - rust-lang#88847 (platform-support.md: correct ARMv7+MUSL platform triple notes)
 - rust-lang#88963 (Coerce const FnDefs to implement const Fn traits )
 - rust-lang#89376 (Fix use after drop in self-profile with llvm events)
 - rust-lang#89422 (Replace whitespaces in doctests' name with dashes)
 - rust-lang#89440 (Clarify a sentence in the documentation of Vec (rust-lang#84488))
 - rust-lang#89441 (Normalize after substituting via `field.ty()`)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@fee1-dead fee1-dead deleted the const-iterator branch November 25, 2021 07:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
F-const_trait_impl `#![feature(const_trait_impl)]` 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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants