about summary refs log tree commit diff
path: root/library/alloc/src/rc.rs
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2025-02-08 21:11:17 +0000
committerbors <bors@rust-lang.org>2025-02-08 21:11:17 +0000
commit43ca9d18e333797f0aa3b525501a7cec8d61a96b (patch)
tree9ddd9f6cedb817b31bb6b0b19e17f8f1a5526b10 /library/alloc/src/rc.rs
parent73bf7947e9ab731bf2764db219cd9cda216a3aed (diff)
parent45771e43babdecb3b6a74776c8ebdc30e0f31d1c (diff)
downloadrust-43ca9d18e333797f0aa3b525501a7cec8d61a96b.tar.gz
rust-43ca9d18e333797f0aa3b525501a7cec8d61a96b.zip
Auto merge of #136747 - matthiaskrgr:rollup-qfiiv4n, r=matthiaskrgr
Rollup of 6 pull requests

Successful merges:

 - #135696 (std: move `io` module out of `pal`, get rid of `sys_common::io`)
 - #136099 (Optimize `Rc::<str>::default()` implementation)
 - #136200 (Generate correct terminate block under Wasm EH)
 - #136626 (create `initial_rustdoc` field in `Build`)
 - #136657 (Make empty-line-after an early clippy lint)
 - #136679 (ci: Use largedisk for loongarch)

r? `@ghost`
`@rustbot` modify labels: rollup
Diffstat (limited to 'library/alloc/src/rc.rs')
-rw-r--r--library/alloc/src/rc.rs4
1 files changed, 3 insertions, 1 deletions
diff --git a/library/alloc/src/rc.rs b/library/alloc/src/rc.rs
index ae3318b839d..05e76ccf685 100644
--- a/library/alloc/src/rc.rs
+++ b/library/alloc/src/rc.rs
@@ -2369,7 +2369,9 @@ impl Default for Rc<str> {
     /// This may or may not share an allocation with other Rcs on the same thread.
     #[inline]
     fn default() -> Self {
-        Rc::from("")
+        let rc = Rc::<[u8]>::default();
+        // `[u8]` has the same layout as `str`.
+        unsafe { Rc::from_raw(Rc::into_raw(rc) as *const str) }
     }
 }