Simplify internals of {Rc,Arc}::default#152591
Open
alexcrichton wants to merge 1 commit intorust-lang:mainfrom
Open
Simplify internals of {Rc,Arc}::default#152591alexcrichton wants to merge 1 commit intorust-lang:mainfrom
{Rc,Arc}::default#152591alexcrichton wants to merge 1 commit intorust-lang:mainfrom
Conversation
Collaborator
|
rustbot has assigned @Mark-Simulacrum. Use Why was this reviewer chosen?The reviewer was selected based on:
|
This comment has been minimized.
This comment has been minimized.
This commit simplifies the internal implementation of `Default` for these two pointer types to have the same performance characteristics as before (a side effect of changes in 131460) while avoid use of internal private APIs of Rc/Arc. To preserve the same codegen as before some non-generic functions needed to be tagged as `#[inline]` as well, but otherwise the same IR is produced before/after this change. The motivation of this commit is I was studying up on the state of initialization of `Arc` and `Rc` and figured it'd be nicer to reduce the use of internal APIs and instead use public stable APIs where possible, even in the implementation itself.
da1ddcf to
ba5ff3d
Compare
alexcrichton
commented
Feb 14, 2026
| @@ -30,8 +31,7 @@ pub fn new_uninit(x: u64) -> Arc<[u64; 1000]> { | |||
| // CHECK-LABEL: @new_uninit_slice | |||
| #[no_mangle] | |||
| pub fn new_uninit_slice(x: u64) -> Arc<[u64]> { | |||
| // CHECK: call alloc::sync::arcinner_layout_for_value_layout | |||
| // CHECK-NOT: call alloc::sync::arcinner_layout_for_value_layout | |||
| // CHECK-NOT: %[[B:.+]] = alloca | |||
Member
Author
There was a problem hiding this comment.
The breadcrumbs for this codegen test points back at #111634 which had to do with internal refactorings about how methods were done. I don't believe that these codegen tests are really all that applicable any more so I did my best to at least keep them somewhat, but the extra #[inline] in this PR effectively means that the internals this test relies on also changed which means that the test needed an update one way or another.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This commit simplifies the internal implementation of
Defaultfor these two pointer types to have the same performance characteristics as before (a side effect of changes in #131460) while avoid use of internal private APIs of Rc/Arc. To preserve the same codegen as before some non-generic functions needed to be tagged as#[inline]as well, but otherwise the same IR is produced before/after this change.The motivation of this commit is I was studying up on the state of initialization of
ArcandRcand figured it'd be nicer to reduce the use of internal APIs and instead use public stable APIs where possible, even in the implementation itself.