Skip to content

terminology: allocated object → allocation #141224

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

RalfJung
Copy link
Member

@RalfJung RalfJung commented May 18, 2025

Rust does not have "objects" in memory so "allocated object" is a somewhat odd name. I am not sure where the term comes from. "object" has been used to refer to allocations already in 1.0 docs; this was apparently later changed to "allocated object".

"Allocation" is already the terminology used in Miri and in the UCG. We should properly move to that terminology, and avoid any confusion about whether Rust has an object memory model. (It does not. Memory contains untyped bytes.)

Cc @rust-lang/opsem @rust-lang/lang

@rustbot
Copy link
Collaborator

rustbot commented May 18, 2025

r? @jhpratt

rustbot has assigned @jhpratt.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels May 18, 2025
@rustbot
Copy link
Collaborator

rustbot commented May 18, 2025

Some changes occurred to the intrinsics. Make sure the CTFE / Miri interpreter
gets adapted for the changes, if necessary.

cc @rust-lang/miri, @RalfJung, @oli-obk, @lcnr

@RalfJung RalfJung added the I-lang-nominated Nominated for discussion during a lang team meeting. label May 18, 2025
@@ -95,24 +95,24 @@
//!
//! [valid value]: ../../reference/behavior-considered-undefined.html#invalid-values
//!
//! ## Allocated object
//! ## Allocation
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will break existing links to #allocated-object. Dos anyone have an idea how we could avoid that?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inline html? Something like:

<a id="allocated-object"></a>

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will break existing links to #allocated-object. Does anyone have an idea how we could avoid that?

Here's what we do in the Reference.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah... but not sure if I can just put that in a doc comment.

@rust-log-analyzer

This comment has been minimized.

@traviscross traviscross added P-lang-drag-2 Lang team prioritization drag level 2.https://rust-lang.zulipchat.com/#narrow/channel/410516-t-lang. T-lang Relevant to the language team, which will review and decide on the PR/issue. and removed T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels May 18, 2025
@traviscross
Copy link
Contributor

Agreed.

@rfcbot fcp merge

@rfcbot
Copy link
Collaborator

rfcbot commented May 18, 2025

Team member @traviscross has proposed to merge this. The next step is review by the rest of the tagged team members:

No concerns currently listed.

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.
See this document for info about what commands tagged team members can give me.

@rfcbot rfcbot added proposed-final-comment-period Proposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off. disposition-merge This issue / PR is in PFCP or FCP with a disposition to merge it. labels May 18, 2025
@traviscross traviscross assigned traviscross and unassigned jhpratt May 18, 2025
@traviscross traviscross added I-lang-easy-decision Issue: The decision needed by the team is conjectured to be easy; this does not imply nomination P-lang-drag-1 Lang team prioritization drag level 1. https://rust-lang.zulipchat.com/#narrow/channel/410516-t-lang and removed P-lang-drag-2 Lang team prioritization drag level 2.https://rust-lang.zulipchat.com/#narrow/channel/410516-t-lang. labels May 21, 2025
@tmandry
Copy link
Member

tmandry commented May 21, 2025

@rfcbot reviewed

@rfcbot rfcbot added final-comment-period In the final comment period and will be merged soon unless new substantive objections are raised. and removed proposed-final-comment-period Proposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off. labels May 21, 2025
@rfcbot
Copy link
Collaborator

rfcbot commented May 21, 2025

🔔 This is now entering its final comment period, as per the review above. 🔔

@scottmcm
Copy link
Member

I could have sworn it came from C++, but looking again I can't see any evidence of that.

So I guess it's from https://llvm.org/docs/LangRef.html#allocated-objects:

An allocated object, memory object, or simply object, is a region of a memory space that is reserved by a memory allocation such as alloca, heap allocation calls, and global variable definitions.

@saethlin
Copy link
Member

Yeah, it came from the LangRef but also according to @nikic "allocated object" isn't even the LLVM internal terminology.

@RalfJung
Copy link
Member Author

Does it come from LLVM? Before llvm/llvm-project@47822c80c1b25 they barely used this term -- it had no definition, was just mentioned in a few places.

@CAD97
Copy link
Contributor

CAD97 commented May 21, 2025

The terminology I think was intended to just use "object" as "thing." Given "allocation" is a functional name for the "thing" being named, and the extra semantics that the term "object" can imply, this is clearly a positive change in my eyes. Especially since there's no clear provenance (pun not intended) on where the "object" name came from.

I at least think I adopted the term "allocated object" to distinguish from the act of allocation — "the allocation" could theoretically refer to either the allocated memory block or the operation that creates it — but I think it's always sufficiently clear from context which is being referred to, and the concept of the "allocated object" is now familiar enough that the risk of "object" misleading readers is greater than that of not recognizing the allocation as a thing that the Abstract Machine cares about.


The one caveat to place on this is that of slicing "allocated objects" — this is easier to discuss if the AM concept has a different name than just the allocation. IIRC the consensus now is that our inbounds pointer arithmetic at least allows movement within the whole allocation, but there was a period where we considered having a ref reborrow tighten the available range. But even if normal reborrows don't subslice, those issues do come up with trying to handle an in-process allocator.

But that's IMHO no reason to complicate this for everybody else who isn't writing an allocator.

@traviscross traviscross removed I-lang-nominated Nominated for discussion during a lang team meeting. I-lang-easy-decision Issue: The decision needed by the team is conjectured to be easy; this does not imply nomination P-lang-drag-1 Lang team prioritization drag level 1. https://rust-lang.zulipchat.com/#narrow/channel/410516-t-lang labels May 21, 2025
LuigiPiucco added a commit to LuigiPiucco/rust that referenced this pull request May 23, 2025
Co-Authored-By: RalfJung <post@ralfj.de>
LuigiPiucco added a commit to LuigiPiucco/rust that referenced this pull request May 24, 2025
This reverts commit aa975c6.

"Allocations" in line 116 in library/core/src/ptr/mod.rs was kept,
however, because it was added as part of this commit series in
rust-lang@5a52202#diff-c175d4e27676febf62c061d31cf9756d256b46e2e44cc6b3177d4ff75e932567R116-R118
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
disposition-merge This issue / PR is in PFCP or FCP with a disposition to merge it. final-comment-period In the final comment period and will be merged soon unless new substantive objections are raised. S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-lang Relevant to the language team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.