From 3ec1810e329bb9dfa0cf0686bdc13558771785d2 Mon Sep 17 00:00:00 2001 From: Taylor Cramer Date: Fri, 14 Sep 2018 17:40:52 -0700 Subject: Cleanup and fix method resolution issue --- src/liballoc/boxed.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/liballoc') 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 Box { } #[unstable(feature = "pin", issue = "49150")] + #[inline(always)] pub fn pinned(x: T) -> Pin> { - unsafe { Pin::new_unchecked(box x) } + (box x).into() } } @@ -434,6 +435,9 @@ impl From for Box { #[unstable(feature = "pin", issue = "49150")] impl From> for Pin> { fn from(boxed: Box) -> Self { + // It's not possible to move or replace the insides of a `Pin>` + // when `T: !Unpin`, so it's safe to pin it directly without any + // additional requirements. unsafe { Pin::new_unchecked(boxed) } } } -- cgit 1.4.1-3-g733a5