Skip to content
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

Reword "object safety" as "trait-object safety" #1512

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

kornelski
Copy link

"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

@kornelski
Copy link
Author

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?

@ehuss
Copy link
Contributor

ehuss commented Jun 18, 2024

To support heading attributes, the version of mdbook in

curl -sSL https://github.com/rust-lang/mdBook/releases/download/v0.4.14/mdbook-v0.4.14-x86_64-unknown-linux-gnu.tar.gz | tar -xz --directory=bin
needs to be updated to the latest version (0.4.40).

@traviscross
Copy link
Contributor

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.

@joshtriplett
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants