Skip to content

Various fixes for const_trait_impl - #89359

Merged
bors merged 4 commits into
rust-lang:masterfrom
fee1-dead-contrib:const-it
Nov 25, 2021
Merged

Various fixes for const_trait_impl#89359
bors merged 4 commits into
rust-lang:masterfrom
fee1-dead-contrib:const-it

Conversation

@fee1-dead

Copy link
Copy Markdown
Member

A few problems I found while making Iterator easier to const-implement.

  1. More generous ~const Drop check.

We check for nested fields with caller bounds.

For example, an ADT type with fields of types A, B, C, check if all of them are either:

  • Bounded (A: ~const Drop, B: Copy)
  • Known to be able to destruct at compile time (C = i32, struct C(i32), C = some_fn)
  1. Don't treat trait functions marked with #[default_method_body_is_const] as stable const fns when checking const_for and const_try feature gates.

I think anyone can review this, so no r? this time.

@fee1-deadfee1-dead added the F-const_trait_impl `#![feature(const_trait_impl)]` label Sep 29, 2021
@rust-highfive

Copy link
Copy Markdown
Contributor

r? @matthewjasper

(rust-highfive has picked a reviewer for you, use r? to override)

@rust-highfiverust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Sep 29, 2021
@fee1-deadfee1-dead changed the title Various bugfixes for const_trait_implVarious fixes for const_trait_implSep 29, 2021
@apirainoapiraino added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Oct 14, 2021
@jackh726

Copy link
Copy Markdown
Member

r? @oli-obk

@bors

bors commented Oct 23, 2021

Copy link
Copy Markdown
Collaborator

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

So ~const Drop bounds already are unlike Drop bounds in that the type does not have to actually implement the Drop trait. Is this noted anywhere?

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Ok. That makes sense now, seeing as there isn't really any other way to easily do it.

@oli-obk

Copy link
Copy Markdown
Contributor

makes sense

r=me after a rebase

@rust-log-analyzer

This comment has been minimized.

@fee1-dead

Copy link
Copy Markdown
MemberAuthor

@bors r=oli-obk

@bors

bors commented Nov 24, 2021

Copy link
Copy Markdown
Collaborator

📌 Commit 4f29f3c has been approved by oli-obk

@borsbors 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 24, 2021
GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this pull request Nov 24, 2021
Various fixes for const_trait_impl
A few problems I found while making `Iterator` easier to const-implement.
1. More generous `~const Drop` check.
We check for nested fields with caller bounds.
For example, an ADT type with fields of types `A`, `B`, `C`, check if all of them are either:
- Bounded (`A: ~const Drop`, `B: Copy`)
- Known to be able to destruct at compile time (`C = i32`, `struct C(i32)`, `C = some_fn`)
2. Don't treat trait functions marked with `#[default_method_body_is_const]` as stable const fns when checking `const_for` and `const_try` feature gates.
I think anyone can review this, so no r? this time.
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Nov 25, 2021
Various fixes for const_trait_impl
A few problems I found while making `Iterator` easier to const-implement.
1. More generous `~const Drop` check.
We check for nested fields with caller bounds.
For example, an ADT type with fields of types `A`, `B`, `C`, check if all of them are either:
- Bounded (`A: ~const Drop`, `B: Copy`)
- Known to be able to destruct at compile time (`C = i32`, `struct C(i32)`, `C = some_fn`)
2. Don't treat trait functions marked with `#[default_method_body_is_const]` as stable const fns when checking `const_for` and `const_try` feature gates.
I think anyone can review this, so no r? this time.
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Nov 25, 2021
Various fixes for const_trait_impl
A few problems I found while making `Iterator` easier to const-implement.
1. More generous `~const Drop` check.
We check for nested fields with caller bounds.
For example, an ADT type with fields of types `A`, `B`, `C`, check if all of them are either:
- Bounded (`A: ~const Drop`, `B: Copy`)
- Known to be able to destruct at compile time (`C = i32`, `struct C(i32)`, `C = some_fn`)
2. Don't treat trait functions marked with `#[default_method_body_is_const]` as stable const fns when checking `const_for` and `const_try` feature gates.
I think anyone can review this, so no r? this time.
bors added a commit to rust-lang-ci/rust that referenced this pull request Nov 25, 2021
…askrgr
Rollup of 6 pull requests
Successful merges:
- rust-lang#89359 (Various fixes for const_trait_impl)
- rust-lang#90499 (Link with default MACOSX_DEPLOYMENT_TARGET if not otherwise specified.)
- rust-lang#91096 (Print associated types on opaque `impl Trait` types)
- rust-lang#91111 (Do not visit attributes in `ItemLowerer`.)
- rust-lang#91162 (explain why CTFE/Miri perform truncation on shift offset)
- rust-lang#91185 (Remove `-Z force-overflow-checks`)
Failed merges:
r? `@ghost`
`@rustbot` modify labels: rollup
@bors
bors merged commit 90dd7c0 into rust-lang:masterNov 25, 2021
@rustbotrustbot added this to the 1.58.0 milestone Nov 25, 2021
Sign up for freeto 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-borsStatus: Waiting on bors to run and complete tests. Bors will change the label on completion.T-compilerRelevant 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.

10 participants

@fee1-dead@rust-highfive@jackh726@bors@oli-obk@rust-log-analyzer@mbartlett21@apiraino@matthewjasper@rustbot