diff options
| author | bors <bors@rust-lang.org> | 2022-06-02 10:39:24 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2022-06-02 10:39:24 +0000 |
| commit | 9598b4b594c97dff66feb93522e22db500deea07 (patch) | |
| tree | 36ef4aa6db5e6cbecaa6b2f10eb8f9df7436babf /library/alloc | |
| parent | 5e6bb83268518dcd74c96b5504f485b71e604e4c (diff) | |
| parent | fa79247826033eff7c422f95d6cda73dd0b211e1 (diff) | |
Auto merge of #97644 - Dylan-DPC:rollup-xaeio91, r=Dylan-DPC
Rollup of 6 pull requests Successful merges: - #96894 (Apply track_caller to closure on `expect_non_local()`) - #97023 (Diagnose anonymous lifetimes errors more uniformly between async and regular fns) - #97397 (Stabilize `box_into_pin`) - #97587 (Migrate more diagnostics to use the `#[derive(SessionDiagnostic)]`) - #97603 (Arc make_mut doc comment spelling correction.) - #97635 (Fix file metadata documentation for Windows) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
Diffstat (limited to 'library/alloc')
| -rw-r--r-- | library/alloc/src/boxed.rs | 23 | ||||
| -rw-r--r-- | library/alloc/src/sync.rs | 6 |
2 files changed, 24 insertions, 5 deletions
diff --git a/library/alloc/src/boxed.rs b/library/alloc/src/boxed.rs index 41f3b1fa3dd..e2c692b5299 100644 --- a/library/alloc/src/boxed.rs +++ b/library/alloc/src/boxed.rs @@ -1175,14 +1175,33 @@ impl<T: ?Sized, A: Allocator> Box<T, A> { /// This conversion does not allocate on the heap and happens in place. /// /// This is also available via [`From`]. - #[unstable(feature = "box_into_pin", issue = "62370")] + /// + /// # Notes + /// + /// It's not recommended that crates add an impl like `From<Box<T>> for Pin<T>`, + /// as it'll introduce an ambiguity when calling `Pin::from`. + /// A demonstration of such a poor impl is shown below. + /// + /// ```compile_fail + /// # use std::pin::Pin; + /// struct Foo; // A type defined in this crate. + /// impl From<Box<()>> for Pin<Foo> { + /// fn from(_: Box<()>) -> Pin<Foo> { + /// Pin::new(Foo) + /// } + /// } + /// + /// let foo = Box::new(()); + /// let bar = Pin::from(foo); + /// ``` + #[stable(feature = "box_into_pin", since = "1.63.0")] #[rustc_const_unstable(feature = "const_box", issue = "92521")] pub const fn into_pin(boxed: Self) -> Pin<Self> where A: 'static, { // It's not possible to move or replace the insides of a `Pin<Box<T>>` - // when `T: !Unpin`, so it's safe to pin it directly without any + // when `T: !Unpin`, so it's safe to pin it directly without any // additional requirements. unsafe { Pin::new_unchecked(boxed) } } diff --git a/library/alloc/src/sync.rs b/library/alloc/src/sync.rs index d5ed3fd18c3..55d51e0a3c4 100644 --- a/library/alloc/src/sync.rs +++ b/library/alloc/src/sync.rs @@ -1393,11 +1393,11 @@ impl<T: Clone> Arc<T> { /// referred to as clone-on-write. /// /// However, if there are no other `Arc` pointers to this allocation, but some [`Weak`] - /// pointers, then the [`Weak`] pointers will be disassociated and the inner value will not + /// pointers, then the [`Weak`] pointers will be dissociated and the inner value will not /// be cloned. /// /// See also [`get_mut`], which will fail rather than cloning the inner value - /// or diassociating [`Weak`] pointers. + /// or dissociating [`Weak`] pointers. /// /// [`clone`]: Clone::clone /// [`get_mut`]: Arc::get_mut @@ -1420,7 +1420,7 @@ impl<T: Clone> Arc<T> { /// assert_eq!(*other_data, 12); /// ``` /// - /// [`Weak`] pointers will be disassociated: + /// [`Weak`] pointers will be dissociated: /// /// ``` /// use std::sync::Arc; |
