-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Mark defaulted PartialEq
/PartialOrd
methods as const
#91439
Mark defaulted PartialEq
/PartialOrd
methods as const
#91439
Conversation
This comment has been minimized.
This comment has been minimized.
cc @oli-obk per https://rust-lang.zulipchat.com/#narrow/stream/146212-t-compiler.2Fconst-eval/topic/default_method_body_is_const Overview of
|
Nominating for T-lang discussion. We want to experimentally and unstably use this never-to-be-stabilized attribute. I'm assuming we're going to add something (e.g. partial or default impls) in the future that allows us to remove the attribute as you could mark such impls as const then. In any case, this is all unstable and reversible until we stabilize the ability for users to call or write const trait impls |
Ah, I didn't think this was novel. My bad. This came up as part of #91386, and it's basically the most obvious use-case for I don't know what's causing miri to fail though. I'm guessing it's not correctly resolving the method to the defaulted one? |
@oli-obk Could you expand a little on the ask from T-lang? " In any case, this is all unstable and reversible until we stabilize the ability for users to call or write const trait impls" makes it sound like there is no risk to this PR, so it's not clear that a discussion is necessary -- if it is, I feel like a concrete question to answer would be helpful to make sure that discussion tries to answer it. |
The question is: are we going to add something (e.g. partial or default impls) in the future that allow us to remove the attribute as you could then mark such impls as const? The reason I ask is that we don't really gate this feature, except for the gate that allows you to call const trait impls. Were we to stabilize any const traits that use this feature, we'd lock ourselves into requiring that we'll have such a feature |
We discussed this in today's @rust-lang/lang meeting. This sounds reasonable to us, as long as it's documented in the tracking issue for const trait impls as a gating consideration for stabilization (e.g. in the top post of such a tracking issue). |
The tracking issue of const trait impls (#67792) tracks this in the main issue comment |
@bors r+ rollup |
📌 Commit dc18d50 has been approved by |
…ult-methods, r=oli-obk Mark defaulted `PartialEq`/`PartialOrd` methods as const WIthout it, `const` impls of these traits are unpleasant to write. I think this kind of change is allowed now. although it looks like it might require some Miri tweaks. Let's find out. r? `@fee1-dead`
@bors r- This is broken, and I still don't know that the bug is. |
Failed in a rollup: #91937 (comment) |
Fix default_method_body_is_const when used across crates r? `@oli-obk` unblocks rust-lang#91439.
Consider rebasing on top of master since the fix (#92001) has landed. |
dc18d50
to
1606335
Compare
This comment has been minimized.
This comment has been minimized.
@bors r=oli-obk |
📌 Commit 2049287 has been approved by |
…ult-methods, r=oli-obk Mark defaulted `PartialEq`/`PartialOrd` methods as const WIthout it, `const` impls of these traits are unpleasant to write. I think this kind of change is allowed now. although it looks like it might require some Miri tweaks. Let's find out. r? `@fee1-dead`
…ult-methods, r=oli-obk Mark defaulted `PartialEq`/`PartialOrd` methods as const WIthout it, `const` impls of these traits are unpleasant to write. I think this kind of change is allowed now. although it looks like it might require some Miri tweaks. Let's find out. r? ``@fee1-dead``
…askrgr Rollup of 7 pull requests Successful merges: - rust-lang#91439 (Mark defaulted `PartialEq`/`PartialOrd` methods as const) - rust-lang#91516 (Improve suggestion to change struct field to &mut) - rust-lang#91896 (Remove `in_band_lifetimes` for `rustc_passes`) - rust-lang#91909 (:arrow_up: rust-analyzer) - rust-lang#91922 (Remove `in_band_lifetimes` from `rustc_mir_dataflow`) - rust-lang#92025 (Revert "socket ancillary data implementation for dragonflybsd.") - rust-lang#92030 (Update stdlib to the 2021 edition) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
WIthout it,
const
impls of these traits are unpleasant to write. I think this kind of change is allowed now. although it looks like it might require some Miri tweaks. Let's find out.r? @fee1-dead