-
Notifications
You must be signed in to change notification settings - Fork 13k
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
Various fixes for const_trait_impl #89359
Conversation
(rust-highfive has picked a reviewer for you, use r? to override) |
r? @oli-obk |
☔ The latest upstream changes (presumably #90104) made this pull request unmergeable. Please resolve the merge conflicts. |
|
||
pub struct Foo<T>(T); | ||
|
||
const fn baz<T: ~const Drop, E: ~const Drop>(res: Result<Foo<T>, Foo<E>>) -> Option<Foo<T>> { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
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.
makes sense r=me after a rebase |
This comment has been minimized.
This comment has been minimized.
@bors r=oli-obk |
📌 Commit 4f29f3c has been approved by |
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.
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.
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.
…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
A few problems I found while making
Iterator
easier to const-implement.~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:A: ~const Drop
,B: Copy
)C = i32
,struct C(i32)
,C = some_fn
)#[default_method_body_is_const]
as stable const fns when checkingconst_for
andconst_try
feature gates.I think anyone can review this, so no r? this time.