@@ -187,6 +187,7 @@ impl<T> Box<T> {
187187 #[ cfg( not( no_global_oom_handling) ) ]
188188 #[ inline( always) ]
189189 #[ stable( feature = "rust1" , since = "1.0.0" ) ]
190+ #[ must_use]
190191 pub fn new ( x : T ) -> Self {
191192 box x
192193 }
@@ -211,6 +212,7 @@ impl<T> Box<T> {
211212 /// ```
212213 #[ cfg( not( no_global_oom_handling) ) ]
213214 #[ unstable( feature = "new_uninit" , issue = "63291" ) ]
215+ #[ must_use]
214216 #[ inline]
215217 pub fn new_uninit ( ) -> Box < mem:: MaybeUninit < T > > {
216218 Self :: new_uninit_in ( Global )
@@ -237,6 +239,7 @@ impl<T> Box<T> {
237239 #[ cfg( not( no_global_oom_handling) ) ]
238240 #[ inline]
239241 #[ unstable( feature = "new_uninit" , issue = "63291" ) ]
242+ #[ must_use]
240243 pub fn new_zeroed ( ) -> Box < mem:: MaybeUninit < T > > {
241244 Self :: new_zeroed_in ( Global )
242245 }
@@ -245,6 +248,7 @@ impl<T> Box<T> {
245248 /// `x` will be pinned in memory and unable to be moved.
246249 #[ cfg( not( no_global_oom_handling) ) ]
247250 #[ stable( feature = "pin" , since = "1.33.0" ) ]
251+ #[ must_use]
248252 #[ inline( always) ]
249253 pub fn pin ( x : T ) -> Pin < Box < T > > {
250254 ( box x) . into ( )
@@ -339,6 +343,7 @@ impl<T, A: Allocator> Box<T, A> {
339343 /// ```
340344 #[ cfg( not( no_global_oom_handling) ) ]
341345 #[ unstable( feature = "allocator_api" , issue = "32838" ) ]
346+ #[ must_use]
342347 #[ inline]
343348 pub fn new_in ( x : T , alloc : A ) -> Self {
344349 let mut boxed = Self :: new_uninit_in ( alloc) ;
@@ -395,6 +400,7 @@ impl<T, A: Allocator> Box<T, A> {
395400 /// ```
396401 #[ unstable( feature = "allocator_api" , issue = "32838" ) ]
397402 #[ cfg( not( no_global_oom_handling) ) ]
403+ #[ must_use]
398404 // #[unstable(feature = "new_uninit", issue = "63291")]
399405 pub fn new_uninit_in ( alloc : A ) -> Box < mem:: MaybeUninit < T > , A > {
400406 let layout = Layout :: new :: < mem:: MaybeUninit < T > > ( ) ;
@@ -459,6 +465,7 @@ impl<T, A: Allocator> Box<T, A> {
459465 #[ unstable( feature = "allocator_api" , issue = "32838" ) ]
460466 #[ cfg( not( no_global_oom_handling) ) ]
461467 // #[unstable(feature = "new_uninit", issue = "63291")]
468+ #[ must_use]
462469 pub fn new_zeroed_in ( alloc : A ) -> Box < mem:: MaybeUninit < T > , A > {
463470 let layout = Layout :: new :: < mem:: MaybeUninit < T > > ( ) ;
464471 // NOTE: Prefer match over unwrap_or_else since closure sometimes not inlineable.
@@ -503,6 +510,7 @@ impl<T, A: Allocator> Box<T, A> {
503510 /// `x` will be pinned in memory and unable to be moved.
504511 #[ cfg( not( no_global_oom_handling) ) ]
505512 #[ unstable( feature = "allocator_api" , issue = "32838" ) ]
513+ #[ must_use]
506514 #[ inline( always) ]
507515 pub fn pin_in ( x : T , alloc : A ) -> Pin < Self >
508516 where
@@ -561,6 +569,7 @@ impl<T> Box<[T]> {
561569 /// ```
562570 #[ cfg( not( no_global_oom_handling) ) ]
563571 #[ unstable( feature = "new_uninit" , issue = "63291" ) ]
572+ #[ must_use]
564573 pub fn new_uninit_slice ( len : usize ) -> Box < [ mem:: MaybeUninit < T > ] > {
565574 unsafe { RawVec :: with_capacity ( len) . into_box ( len) }
566575 }
@@ -585,6 +594,7 @@ impl<T> Box<[T]> {
585594 /// [zeroed]: mem::MaybeUninit::zeroed
586595 #[ cfg( not( no_global_oom_handling) ) ]
587596 #[ unstable( feature = "new_uninit" , issue = "63291" ) ]
597+ #[ must_use]
588598 pub fn new_zeroed_slice ( len : usize ) -> Box < [ mem:: MaybeUninit < T > ] > {
589599 unsafe { RawVec :: with_capacity_zeroed ( len) . into_box ( len) }
590600 }
@@ -681,6 +691,7 @@ impl<T, A: Allocator> Box<[T], A> {
681691 #[ cfg( not( no_global_oom_handling) ) ]
682692 #[ unstable( feature = "allocator_api" , issue = "32838" ) ]
683693 // #[unstable(feature = "new_uninit", issue = "63291")]
694+ #[ must_use]
684695 pub fn new_uninit_slice_in ( len : usize , alloc : A ) -> Box < [ mem:: MaybeUninit < T > ] , A > {
685696 unsafe { RawVec :: with_capacity_in ( len, alloc) . into_box ( len) }
686697 }
@@ -708,6 +719,7 @@ impl<T, A: Allocator> Box<[T], A> {
708719 #[ cfg( not( no_global_oom_handling) ) ]
709720 #[ unstable( feature = "allocator_api" , issue = "32838" ) ]
710721 // #[unstable(feature = "new_uninit", issue = "63291")]
722+ #[ must_use]
711723 pub fn new_zeroed_slice_in ( len : usize , alloc : A ) -> Box < [ mem:: MaybeUninit < T > ] , A > {
712724 unsafe { RawVec :: with_capacity_zeroed_in ( len, alloc) . into_box ( len) }
713725 }
0 commit comments