-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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
Decide on name for Freeze
#131401
Comments
I'm reiterating my proposal from Zulip: keeping
|
Let's see whether we have consensus to simply call it @rfcbot fcp merge |
Team member @traviscross has proposed to merge this. The next step is review by the rest of the tagged team members: Concerns:
Once a majority of reviewers approve (and at most 2 approvals are outstanding), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up! cc @rust-lang/lang-advisors: FCP proposed for lang, please feel free to register concerns. |
I don't know if |
@rfcbot concern should-be-self-documenting-about-interior-mutability I think we should use a name that's self-documenting and evokes the concept of interior mutability in some way. |
Would |
I'm partial to the name |
Stylistically, we don't end trait names with "-able". We have That is, trait names imply the capability to do the thing named in the trait. What would be the version of an "interior immutable"-style name that matches that? |
While "mutable" has a verb form "mutate", there isn't any verb equivalent of "immutable" ("not mutate"?). I would therefore argue for an exception to the -able policy for this specific case since "immutable" very clearly captures what this trait is promising. An alternative that also captures the concept of interior mutability are might be |
Some variants to get the juices going:
|
The "action" this trait lets one do is know that if we do two reads from (pointers derived from) a reference where the pointee has this trait, we will get the same value. I don't know how to make that into a nice trait name...
|
What @RalfJung said is why I don't hate I.e., inventing some notation, we could imagine the trait as: trait Freeze {
fn freeze(&self) -> &frozen Self;
} |
Maybe |
I could live with |
@traviscross I'd prefer |
@traviscross This RFC is becoming stale again, with bike-shedding around the trait's name looking like the main blocker. Do you think setting a deadline on the decision of naming (and possibly a poll with some of the existing options) could help push forward? |
It's a good point. We just need to allocate some time for it in a meeting and commit to the bikeshed. There's a meeting in mid December we have scheduled that would probably make sense for that. |
@traviscross Any timeline to try to get this sorted? The breaking change that pushed the need for this is still a major thorn in |
No, unfortunately. What I can say is that clearing the backlog of things like this is high on my priority list, and I have some plans about how we might do that. |
Is there any way I can be helpful in the process? :) |
Would it make sense to instead of the trait Freeze, have its negation NoFreeze, expressing the fact that some type does have an UnsafeCell somewhere in its representation, instead of the absence of that? Name could be InteriorMut(ate) or InternalChange or InnerMut(ate) or InnerChange or something like that... "core::marker::Freeze is a trait that is implemented for any type whose memory layout doesn't contain any UnsafeCell: it indicates that the memory referenced by &T is guaranteed not to change while the reference is live." -- the RFC |
The problem with that is that since you can't make negative bounds, such a trait wouldn't have much use, as its usefulness stands from the particular properties On the other hand, I've wanted negative bounds for so long that if this bikesheding ends up being the final nail in that coffin, I'd wouldn't even be mad; but I somehow doubt that would happen :D |
We may need a design meeting to resolve this, and for that we'll need a design document that collects the options that have been proposed and the arguments that have been made about them and then proposes a plan. If you could put that together, it'd help. I'll reach out separately about this on Zulip. |
Given that the major caveat of this trait is that it only implies immutability up until some form of indirection, I'm surprised that nobody has proposed Aside, one of the reasons that I don't like |
I wanted to brain storm a little about what action this trait enables, so I went back to the RFC: "Orthogonally to static-promotion, "static-promotion" seems to be about "previously, const REF: &T = &expr; was (accidentally) accepted even when expr may contain interior mutability. Now this requires that the type of expr satisfies T: core::marker::Freeze" so should perhaps be changed to "const-promotion" (with or without dash), so that gives the first option of ConstPromote. Then there is the conversion from Then I wondered what the purpose is of this ref transmute. Is it for enabling some optimization? That would give OptimizeX. Bytemuck seems to use Zeroable, NoUninit, AnyBitPattern among other traits, while ZeroCopy has KnownLayout, Immutable, Unaligned, and IntoBytes. Actually it seems not Immutable (as claimed by the RFC) but this IntoBytes is what is used for this transmuting meaning of Freeze: "Any IntoBytes type can be converted to a slice of initialized bytes of the same size. This is useful for efficiently serializing structured data as raw bytes." Why does the RFC (on a very cursory viewing) seem to suggest that Immutable and IntoBytes are the same? Or perhaps, why does zerocopy separate these traits? Options:
|
We still need to pick a name for
Freeze
(which may still beFreeze
) so that we can proceed with:core::marker::Freeze
in bounds rfcs#3633Thoughts?
cc @rust-lang/lang
@rustbot labels +T-lang +I-lang-nominated
The text was updated successfully, but these errors were encountered: