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

Use a single static for all default slice Arcs. #125283

Merged
merged 5 commits into from
May 20, 2024

Conversation

zachs18
Copy link
Contributor

@zachs18 zachs18 commented May 19, 2024

Also adds debug_asserts in Drop for Weak/Arc that the shared static is not being "dropped"/"deallocated".

As per #124640 (review)

r? dtolnay

Also adds debug_asserts in Drop for Weak/Arc that the shared static is not being "dropped"/"deallocated".
@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels May 19, 2024
@rust-log-analyzer

This comment has been minimized.

Copy link
Member

@dtolnay dtolnay left a comment

Choose a reason for hiding this comment

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

Thank you!

Adding the debug asserts in Drop is a wonderful idea.

library/alloc/src/sync.rs Outdated Show resolved Hide resolved
library/alloc/src/sync.rs Outdated Show resolved Hide resolved
struct SliceArcInnerForStatic {
inner: ArcInner<[u8; 1]>,
}
const MAX_STATIC_INNER_SLICE_ALIGNMENT: usize = 16;
Copy link
Member

Choose a reason for hiding this comment

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

This needs a #[cfg(not(no_global_oom_handling))], since the Default impls using this only exist in that configuration.

Optionally we can put #[cfg(not(no_global_oom_handling))] on STATIC_INNER_SLICE too, and the debug-asserts in Drop, but it doesn't really hurt without.

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels May 19, 2024
@dtolnay
Copy link
Member

dtolnay commented May 19, 2024

@bors r+

@bors
Copy link
Contributor

bors commented May 19, 2024

📌 Commit 3299823 has been approved by dtolnay

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels May 19, 2024
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request May 20, 2024
Use a single static for all default slice Arcs.

Also adds debug_asserts in Drop for Weak/Arc that the shared static is not being "dropped"/"deallocated".

As per rust-lang#124640 (review)

r? dtolnay
fmease added a commit to fmease/rust that referenced this pull request May 20, 2024
Use a single static for all default slice Arcs.

Also adds debug_asserts in Drop for Weak/Arc that the shared static is not being "dropped"/"deallocated".

As per rust-lang#124640 (review)

r? dtolnay
bors added a commit to rust-lang-ci/rust that referenced this pull request May 20, 2024
…iaskrgr

Rollup of 5 pull requests

Successful merges:

 - rust-lang#125219 (Update `unexpected_cfgs` lint for Cargo new `check-cfg` config)
 - rust-lang#125255 (Make `EvalCtxt` generic over `InferCtxtLike`)
 - rust-lang#125283 (Use a single static for all default slice Arcs.)
 - rust-lang#125300 (rustdoc: Don't strip items with inherited visibility in `AliasedNonLocalStripper`)
 - rust-lang#125309 (Fix `tests/debuginfo/strings-and-strs`.)

r? `@ghost`
`@rustbot` modify labels: rollup
bors added a commit to rust-lang-ci/rust that referenced this pull request May 20, 2024
…iaskrgr

Rollup of 4 pull requests

Successful merges:

 - rust-lang#125255 (Make `EvalCtxt` generic over `InferCtxtLike`)
 - rust-lang#125283 (Use a single static for all default slice Arcs.)
 - rust-lang#125300 (rustdoc: Don't strip items with inherited visibility in `AliasedNonLocalStripper`)
 - rust-lang#125309 (Fix `tests/debuginfo/strings-and-strs`.)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit d1da238 into rust-lang:master May 20, 2024
6 checks passed
@rustbot rustbot added this to the 1.80.0 milestone May 20, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request May 20, 2024
Rollup merge of rust-lang#125283 - zachs18:arc-default-shared, r=dtolnay

Use a single static for all default slice Arcs.

Also adds debug_asserts in Drop for Weak/Arc that the shared static is not being "dropped"/"deallocated".

As per rust-lang#124640 (review)

r? dtolnay
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-libs Relevant to the library team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants