Uh oh!
There was an error while loading. Please reload this page.
Implement Rc/Arc conversions for string-like types - #45990
Conversation
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.
murarth
commented
Nov 14, 2017
Tests passed. r? @kennytm |
kennytm
commented
Nov 15, 2017
r? @BurntSushi |
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]>
Centril
commented
Nov 15, 2017
This is continuation of |
BurntSushi
commented
Nov 15, 2017
This seems reasonable to me! @rfcbot merge |
kennytm
commented
Nov 15, 2017
@BurntSushi The correct command is |
BurntSushi
commented
Nov 15, 2017
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. |
kennytm
commented
Nov 22, 2017
Ping @Kimundi, ticky boxes for you! |
rfcbot
commented
Nov 22, 2017
🔔 This is now entering its final comment period, as per the review above. 🔔 |
alexcrichton
commented
Nov 25, 2017
@bors: r+ |
bors
commented
Nov 25, 2017
📌 Commit 3c1d59f has been approved by |
bors
commented
Nov 25, 2017
⌛ Testing commit 3c1d59f61817c4470ebbaa17c925633c71cb1fd3 with merge b199f97bdde51ed7ad4c16799c3ef05a354428e1... |
bors
commented
Nov 25, 2017
💔 Test failed - status-appveyor |
kennytm
commented
Nov 25, 2017
Could not compile stage0-libstd on all Windows, missing imports. |
murarth
commented
Nov 25, 2017
@kennytm: Fixed. re-r+? |
kennytm
commented
Nov 25, 2017
@bors r=alexcrichton |
bors
commented
Nov 25, 2017
📌 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>`
Closesrust-lang#45008bors
commented
Nov 26, 2017
⌛ Testing commit 85e6421 with merge 5600b272ddaffa84cdbbdf4872a89a2680d72ccf... |
bors
commented
Nov 26, 2017
💔 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>`murarth
commented
Nov 26, 2017
Psh. The wasm stuff merged and added a new |
kennytm
commented
Nov 26, 2017
@bors r=alexcrichton |
bors
commented
Nov 26, 2017
📌 Commit 1bbc776 has been approved by |
bors
commented
Nov 26, 2017
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#45008bors
commented
Nov 26, 2017
☀️ 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