diff options
| author | Taylor Cramer <cramertj@google.com> | 2018-09-14 17:40:52 -0700 |
|---|---|---|
| committer | Taylor Cramer <cramertj@google.com> | 2018-09-17 16:31:33 -0700 |
| commit | 3ec1810e329bb9dfa0cf0686bdc13558771785d2 (patch) | |
| tree | bb9f39ea9e7c740e1b8635f77868b3948a1e5b99 /src/liballoc | |
| parent | 974bdc80fe3214159dc30e0bbb76694900e613c0 (diff) | |
| download | rust-3ec1810e329bb9dfa0cf0686bdc13558771785d2.tar.gz rust-3ec1810e329bb9dfa0cf0686bdc13558771785d2.zip | |
Cleanup and fix method resolution issue
Diffstat (limited to 'src/liballoc')
| -rw-r--r-- | src/liballoc/boxed.rs | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/liballoc/boxed.rs b/src/liballoc/boxed.rs index fce6417186f..744b611c061 100644 --- a/src/liballoc/boxed.rs +++ b/src/liballoc/boxed.rs @@ -98,8 +98,9 @@ impl<T> Box<T> { } #[unstable(feature = "pin", issue = "49150")] + #[inline(always)] pub fn pinned(x: T) -> Pin<Box<T>> { - unsafe { Pin::new_unchecked(box x) } + (box x).into() } } @@ -434,6 +435,9 @@ impl<T> From<T> for Box<T> { #[unstable(feature = "pin", issue = "49150")] impl<T> From<Box<T>> for Pin<Box<T>> { fn from(boxed: Box<T>) -> Self { + // 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 + // additional requirements. unsafe { Pin::new_unchecked(boxed) } } } |
