Skip to content

Remove some dead code in DroplessArena. - #159053

Open
nnethercote wants to merge 1 commit into
rust-lang:mainfrom
nnethercote:arena-dead-code
Open

Remove some dead code in DroplessArena.#159053
nnethercote wants to merge 1 commit into
rust-lang:mainfrom
nnethercote:arena-dead-code

Conversation

@nnethercote

Copy link
Copy Markdown
Contributor

PR 155325 disallowed ZSTs in DroplessArena. This commit removes some dead code paths that were missed in that PR.

r? @Nadrieril

PR 155325 disallowed ZSTs in `DroplessArena`. This commit removes some
dead code paths that were missed in that PR.
@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. labels Jul 10, 2026
@rustbot

rustbot commented Jul 10, 2026

Copy link
Copy Markdown
Collaborator

Nadrieril is currently at their maximum review capacity.
They may take a while to respond.

Comment on lines -260 to +253
let elem_size = cmp::max(1, size_of::<T>());
let elem_size = size_of::<T>();

@Nadrieril Nadrieril Jul 10, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Could you add a comment explaning that we forbidded ZSTs earlier? Or even an assert

View changes since the review


impl<T> ArenaChunk<T> {
#[inline]
unsafe fn new(capacity: usize) -> ArenaChunk<T> {

@Nadrieril Nadrieril Jul 10, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This should have a safety comment saying to not use on ZSTs, and an assert!(size_of::<T>() > 0)

View changes since the review

Comment on lines 120 to 121
fn default() -> TypedArena<T> {
TypedArena {

@Nadrieril Nadrieril Jul 10, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can you assert T isn't a ZST?

View changes since the review

@Nadrieril

Copy link
Copy Markdown
Member

#155325 isn't the right PR, do you have the link to the right one handy?

@nnethercote

Copy link
Copy Markdown
Contributor Author

#155325 isn't the right PR, do you have the link to the right one handy?

Off by one, it was #155326.

@nnethercote

Copy link
Copy Markdown
Contributor Author

About the asserts: we already have eight assertions in this file that the size of T is non-zero, four in TypedArena and four in DroplessArena. I'm not sure adding another three will achieve much?

@Nadrieril

Nadrieril commented Jul 13, 2026

Copy link
Copy Markdown
Member

You can create an ArenaChunk<()>::new(..) without any asserts, and same for TypedArena::<()>::default(), seems bad no?

@euclio

euclio commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Could a single const assert be added on the size of T?

@nnethercote

Copy link
Copy Markdown
Contributor Author

Could a single const assert be added on the size of T?

I don't think so: the assertion would need to be within a function like alloc<T>, but const items can't use generic parameters such as T from an outer item.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants