Uh oh!
There was an error while loading. Please reload this page.
Generalize {Rc,Arc}::make_mut() to unsized types. - #116113
Conversation
rustbot
commented
Sep 23, 2023
r? @thomcc (rustbot has picked a reviewer for you, use r? to override) |
kpreid
commented
Sep 23, 2023
@rustbot label +T-libs-api |
This comment has been minimized.
This comment has been minimized.
thomcc
commented
Sep 24, 2023
This is insta-stable, so it needs libs-api FCP. r? @rust-lang/libs-api |
thomcc
commented
Sep 24, 2023
Rerolling because @BurntSushi doesn't do libs reviews. r? rust-lang/libs-api |
There was a problem hiding this comment.
How about adjusting the trait bound on make_mut instead? It can be implemented the current way for T: Clone and separately for [T].
impl<T:CanMakeMut,A:Allocator + Clone>Arc<T,A>{pubfnmake_mut(this:&mutSelf) -> &mutT{ ...}}impl<T:Clone>CanMakeMutforT{ ... }impl<T:Clone>CanMakeMutfor[T]{ ... }
Is it? The current commit only adds unstable inherent methods. There's no trait implementation involved.
I like that idea much better since it doesn't add a new name. (Though it would be insta-stable.) I'm not familiar with how introducing a trait like Actually, the trait could be of more broad use — it seems like it could be a general "clone |
thomcc
commented
Sep 24, 2023
Oh, it's totally not insta-stable, my bad (sorry, been a draining couple of weeks for me). Still, I'll leave the review to the assignee at this point. |
dtolnay
commented
Sep 24, 2023
The I would definitely be on board with a trait that allows cloning into a pre-allocated I am not familiar with the |
Uh oh!
There was an error while loading. Please reload this page.
kpreid
commented
Sep 24, 2023
Observation: The new |
kpreid
commented
Sep 24, 2023
Observation: It's not possible to define these operations in terms of |
This comment has been minimized.
This comment has been minimized.
kpreid
commented
Sep 25, 2023
It was quite an adventure, but I believe I've got it all set now. I had to introduce additional helper types at both the Note that |
{Rc, Arc}::make_mut_slice().{Rc,Arc}::make_mut() to unsized types.kpreid
commented
Sep 25, 2023
Updated PR description with the new design based on |
This comment has been minimized.
This comment has been minimized.
…iaskrgr Rollup of 3 pull requests Successful merges: - rust-lang#116113 ( Generalize `{Rc,Arc}::make_mut()` to unsized types.) - rust-lang#126686 (Add `#[rustc_dump_{predicates,item_bounds}]`) - rust-lang#126731 (Bootstrap command refactoring: refactor `BootstrapCommand` (step 1)) r? `@ghost` `@rustbot` modify labels: rollup
matthiaskrgr
commented
Jun 22, 2024
| @@ -1,3 +1,7 @@ | |||
| use core::clone::CloneToUninit; | |||
| use core::mem::MaybeUninit; | |||
| use core::sync::atomic::{AtomicUsize, Ordering::Relaxed}; | |||
There was a problem hiding this comment.
| use core::sync::atomic::{AtomicUsize,Ordering::Relaxed}; | |
| #[cfg(panic = "unwind")] | |
| use core::sync::atomic::{AtomicUsize,Ordering::Relaxed}; |
(or move the use inside test_clone_to_uninit_slice_drops_on_panic())
error: unused imports: `AtomicUsize` and `Ordering::Relaxed`
--> library/core/tests/clone.rs:3:26
|
3 | use core::sync::atomic::{AtomicUsize, Ordering::Relaxed};
| ^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^
|
= note: `-D unused-imports` implied by `-D warnings`
= help: to override `-D warnings` add `#[allow(unused_imports)]`
There was a problem hiding this comment.
Fixed, I hope.
Is there a way I could check this locally? I tried ./x test library/core --target=wasm32-unknown-unknown but it fails on profiler_builtins before getting to emitting warnings for core.
This trait allows cloning DSTs, but is unsafe to implement and use because it writes to possibly-uninitialized memory which must be of the correct size, and must initialize that memory. It is only implemented for `T: Clone` and `[T] where T: Clone`, but additional implementations could be provided for specific `dyn Trait` or custom-DST types.
This requires introducing a new internal type `RcUninit` (and `ArcUninit`), which can own an `RcBox<T>` without requiring it to be initialized, sized, or a slice. This is similar to `UniqueRc`, but `UniqueRc` doesn't support the allocator parameter, and there is no `UniqueArc`.
dtolnay
commented
Jun 22, 2024
@bors r+ |
bors
commented
Jun 22, 2024
bors
commented
Jun 22, 2024
bors
commented
Jun 22, 2024
☀️ Test successful - checks-actions |
rust-timer
commented
Jun 22, 2024
Finished benchmarking commit (f944afe): comparison URL. Overall result: ❌ regressions - ACTION NEEDEDNext Steps: If you can justify the regressions found in this perf run, please indicate this with @rustbot label: +perf-regression Instruction countThis is a highly reliable metric that was used to determine the overall result at the top of this comment.
Max RSS (memory usage)Results (primary -5.7%, secondary -2.2%)This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
CyclesThis benchmark run did not return any relevant results for this metric. Binary sizeResults (primary 0.1%, secondary 0.3%)This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
Bootstrap: 694.577s -> 694.429s (-0.02%) |
Mark-Simulacrum
commented
Jun 23, 2024
Regressions are mostly in doc benchmarks, seem likely to be just new docs due to extra stuff in the standard library. |
{Rc,Arc}::make_mut()now accept any type implementing the new unstable traitcore::clone::CloneToUninit.CloneToUninitis implemented forT: Cloneand for[T] where T: Clone.CloneToUninitis a generalization of the existing internal traitalloc::alloc::WriteCloneIntoRaw.clone_to_uninitThis allows performing
make_mut()onRc<[T]>andArc<[T]>, which was not previously possible.Previous PR description, now obsolete:
try-job: test-various