Implement Rc/Arc conversions for string-like types#45990
Implement Rc/Arc conversions for string-like types#45990bors merged 1 commit intorust-lang:masterfrom murarth:rc-from-strs
Rc/Arc conversions for string-like types#45990Conversation
src/libstd/ffi/c_str.rs
Outdated
There was a problem hiding this comment.
Could we do this via Arc::into_raw + x as *const CStr + Arc::from_raw instead of transmute?
There was a problem hiding this comment.
Sure. I've now replaced each instance of transmute.
|
Tests passed. r? @kennytm |
|
r? @BurntSushi |
src/libstd/ffi/c_str.rs
Outdated
There was a problem hiding this comment.
Why is this safe? What guarantees that &'a CStr outlives the resulting Arc<CStr>?
There was a problem hiding this comment.
Why would &'a CStr need to outlive Arc<CStr>? Arc::from does a new heap allocation and copies over all the contents of s.
The unsafe block just does Arc<[u8]> -> Arc<CStr>. This is safe since the invariants of CStr are maintained.
There was a problem hiding this comment.
Oh I see. I didn't realize there was a copy here. In hindsight, the Arc<[u8]> type should have told me that. And of course this impl: https://doc.rust-lang.org/std/sync/struct.Arc.html#impl-From<&'a [T]>
|
This is continuation of |
|
This seems reasonable to me! @rfcbot merge |
|
@BurntSushi The correct command is |
|
Let's try it again... @rfcbot fcp merge |
|
Team member @BurntSushi has proposed to merge this. The next step is review by the rest of the tagged teams: No concerns currently listed. Once these reviewers reach consensus, 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! See this document for info about what commands tagged team members can give me. |
|
Ping @Kimundi, ticky boxes for you! |
|
🔔 This is now entering its final comment period, as per the review above. 🔔 |
|
@bors: r+ |
|
📌 Commit 3c1d59f has been approved by |
|
⌛ Testing commit 3c1d59f61817c4470ebbaa17c925633c71cb1fd3 with merge b199f97bdde51ed7ad4c16799c3ef05a354428e1... |
|
💔 Test failed - status-appveyor |
Could not compile stage0-libstd on all Windows, missing imports. |
|
@kennytm: Fixed. re-r+? |
|
@bors r=alexcrichton |
|
📌 Commit 85e6421 has been approved by |
Implement `Rc`/`Arc` conversions for string-like types
Provides the following conversion implementations:
* `From<`{`CString`,`&CStr`}`>` for {`Arc`,`Rc`}`<CStr>`
* `From<`{`OsString`,`&OsStr`}`>` for {`Arc`,`Rc`}`<OsStr>`
* `From<`{`PathBuf`,`&Path`}`>` for {`Arc`,`Rc`}`<Path>`
Closes rust-lang#45008
|
⌛ Testing commit 85e6421 with merge 5600b272ddaffa84cdbbdf4872a89a2680d72ccf... |
|
💔 Test failed - status-travis |
Provides the following conversion implementations:
* `From<`{`CString`,`&CStr`}`>` for {`Arc`,`Rc`}`<CStr>`
* `From<`{`OsString`,`&OsStr`}`>` for {`Arc`,`Rc`}`<OsStr>`
* `From<`{`PathBuf`,`&Path`}`>` for {`Arc`,`Rc`}`<Path>`
|
Psh. The wasm stuff merged and added a new |
|
@bors r=alexcrichton |
|
📌 Commit 1bbc776 has been approved by |
Implement `Rc`/`Arc` conversions for string-like types
Provides the following conversion implementations:
* `From<`{`CString`,`&CStr`}`>` for {`Arc`,`Rc`}`<CStr>`
* `From<`{`OsString`,`&OsStr`}`>` for {`Arc`,`Rc`}`<OsStr>`
* `From<`{`PathBuf`,`&Path`}`>` for {`Arc`,`Rc`}`<Path>`
Closes #45008
|
☀️ Test successful - status-appveyor, status-travis |
Correct a few stability attributes * The extra impls for `ManuallyDrop` were added in rust-lang#44310 which was only stabilised in 1.22.0. * The impls for `SliceIndex` were stabilised in rust-lang#43373 but as `RangeInclusive` and `RangeToInclusive` are still unstable the impls should remain unstable. * The `From` impls for atomic integers were added in rust-lang#45610 but most atomic integers are still unstable. * The `shared_from_slice2` impls were added in rust-lang#45990 but they won't be stable until 1.24.0. * The `Mutex` and `RwLock` impls were added in rust-lang#46082 but won't be stable until 1.24.0.
Correct a few stability attributes * The extra impls for `ManuallyDrop` were added in rust-lang#44310 which was only stabilised in 1.22.0. * The impls for `SliceIndex` were stabilised in rust-lang#43373 but as `RangeInclusive` and `RangeToInclusive` are still unstable the impls should remain unstable. * The `From` impls for atomic integers were added in rust-lang#45610 but most atomic integers are still unstable. * The `shared_from_slice2` impls were added in rust-lang#45990 but they won't be stable until 1.24.0. * The `Mutex` and `RwLock` impls were added in rust-lang#46082 but won't be stable until 1.24.0.
Correct a few stability attributes * The extra impls for `ManuallyDrop` were added in rust-lang#44310 which was only stabilised in 1.22.0. * The impls for `SliceIndex` were stabilised in rust-lang#43373 but as `RangeInclusive` and `RangeToInclusive` are still unstable the impls should remain unstable. * The `From` impls for atomic integers were added in rust-lang#45610 but most atomic integers are still unstable. * The `shared_from_slice2` impls were added in rust-lang#45990 but they won't be stable until 1.24.0. * The `Mutex` and `RwLock` impls were added in rust-lang#46082 but won't be stable until 1.24.0.
Provides the following conversion implementations:
From<{CString,&CStr}>for {Arc,Rc}<CStr>From<{OsString,&OsStr}>for {Arc,Rc}<OsStr>From<{PathBuf,&Path}>for {Arc,Rc}<Path>Closes #45008