reference
reference copied to clipboard
Reword "object safety" as "trait-object safety"
"Object safe" is not a self-explanatory term.
The the word "object" doesn't have a clear definition in Rust's context, and to users it may not be obvious that the term refers to trait objects specifically.
The "safe" part is not good either, because it could be misunderstood as relating to "safe Rust" or not-unsafe.
However, the term "object safe" is used in a lot of places, so I propose a minimal backwards-compatible fix by calling this concept "trait-object safety". Addition of the word "trait" adds context, and clearly connects it to trait objects.
Users may only know this concept from Box<dyn Trait> types, so I'm also emphasising dyn Trait compatibility.
More in the forum thread: https://internals.rust-lang.org/t/object-safety-is-a-terrible-term/21025
It's odd that the link checker doesn't get the right anchor, even tough when I run mdbook build locally, it writes the correct one. It seems like {#anchor} syntax isn't always supported?
To support heading attributes, the version of mdbook in https://github.com/rust-lang/reference/blob/0b805c65804019b0ac8f2fe3117afad82a6069b8/.github/workflows/main.yml#L22 needs to be updated to the latest version (0.4.40).
We discussed this in a rustdocs call. We're going to let the discussion on IRLO play out a bit further, then we may lang nominate this.
However, the term "object safe" is used in a lot of places, so I propose a minimal backwards-compatible fix by calling this concept "trait-object safety".
We've definitely been using the term "object safe" or "object safety" for a long time in many places, so we don't want to leave people unable to look up that term. But I don't think that means we need to leave the term substantially unmodified; I think that means we need to leave plenty of pointers to what we used to call it.
I would suggest, instead, that we fully rebrand this as "dyn Trait compatible" (or, when appropriate, "compatible with dyn Trait" or "dyn-compatible"), and then include notes saying things like "This is sometimes also called 'trait-object safety', 'object safety', or 'object safe'." With that, plus keeping the old link anchors working (though we should add new ones as well to avoid making the old ones look like the canonical names), I think that'll be sufficient to not abandon people who already know the existing term.
@rustbot labels -S-waiting-on-team
When this ongoing FCP completes, we will have decided to call traits that are compatible with dyn "dyn compatible" rather than "object safe".
@rustbot author
Competing PR: #1666.
Closing in favor of #1666.