diff options
| author | bors <bors@rust-lang.org> | 2021-10-11 14:16:15 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2021-10-11 14:16:15 +0000 |
| commit | 1067e2ca5e9cfe5c79f956e49ffc684c5142d49b (patch) | |
| tree | e5f2a3b0156efd5a28e933c42629ce4b443f0b9a /library/alloc/src | |
| parent | 6ae8912a3e7d2c4c775024f58a7ba4b1aedc4073 (diff) | |
| parent | 913b1de0ec1da8cdf5e8ad1c418fe4ad61e1e79d (diff) | |
| download | rust-1067e2ca5e9cfe5c79f956e49ffc684c5142d49b.tar.gz rust-1067e2ca5e9cfe5c79f956e49ffc684c5142d49b.zip | |
Auto merge of #89767 - GuillaumeGomez:rollup-sczixhk, r=GuillaumeGomez
Rollup of 7 pull requests Successful merges: - #89655 (bootstrap: don't use `--merges` to look for commit hashes for downloading artifacts) - #89726 (Add #[must_use] to alloc constructors) - #89729 (Add #[must_use] to core and std constructors) - #89743 (Fix RUSTC_LOG handling) - #89753 (Add #[must_use] to from_value conversions) - #89754 (Cleanup .item-table CSS) - #89761 (:arrow_up: rust-analyzer) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
Diffstat (limited to 'library/alloc/src')
| -rw-r--r-- | library/alloc/src/boxed.rs | 12 | ||||
| -rw-r--r-- | library/alloc/src/collections/binary_heap.rs | 2 | ||||
| -rw-r--r-- | library/alloc/src/collections/btree/map.rs | 1 | ||||
| -rw-r--r-- | library/alloc/src/collections/btree/set.rs | 1 | ||||
| -rw-r--r-- | library/alloc/src/collections/linked_list.rs | 1 | ||||
| -rw-r--r-- | library/alloc/src/collections/vec_deque/mod.rs | 2 | ||||
| -rw-r--r-- | library/alloc/src/raw_vec.rs | 3 | ||||
| -rw-r--r-- | library/alloc/src/rc.rs | 6 | ||||
| -rw-r--r-- | library/alloc/src/str.rs | 1 | ||||
| -rw-r--r-- | library/alloc/src/string.rs | 3 | ||||
| -rw-r--r-- | library/alloc/src/sync.rs | 6 | ||||
| -rw-r--r-- | library/alloc/src/vec/mod.rs | 2 |
12 files changed, 40 insertions, 0 deletions
diff --git a/library/alloc/src/boxed.rs b/library/alloc/src/boxed.rs index 85f908a7f5c..bd4f5256042 100644 --- a/library/alloc/src/boxed.rs +++ b/library/alloc/src/boxed.rs @@ -187,6 +187,7 @@ impl<T> Box<T> { #[cfg(not(no_global_oom_handling))] #[inline(always)] #[stable(feature = "rust1", since = "1.0.0")] + #[must_use] pub fn new(x: T) -> Self { box x } @@ -211,6 +212,7 @@ impl<T> Box<T> { /// ``` #[cfg(not(no_global_oom_handling))] #[unstable(feature = "new_uninit", issue = "63291")] + #[must_use] #[inline] pub fn new_uninit() -> Box<mem::MaybeUninit<T>> { Self::new_uninit_in(Global) @@ -237,6 +239,7 @@ impl<T> Box<T> { #[cfg(not(no_global_oom_handling))] #[inline] #[unstable(feature = "new_uninit", issue = "63291")] + #[must_use] pub fn new_zeroed() -> Box<mem::MaybeUninit<T>> { Self::new_zeroed_in(Global) } @@ -245,6 +248,7 @@ impl<T> Box<T> { /// `x` will be pinned in memory and unable to be moved. #[cfg(not(no_global_oom_handling))] #[stable(feature = "pin", since = "1.33.0")] + #[must_use] #[inline(always)] pub fn pin(x: T) -> Pin<Box<T>> { (box x).into() @@ -339,6 +343,7 @@ impl<T, A: Allocator> Box<T, A> { /// ``` #[cfg(not(no_global_oom_handling))] #[unstable(feature = "allocator_api", issue = "32838")] + #[must_use] #[inline] pub fn new_in(x: T, alloc: A) -> Self { let mut boxed = Self::new_uninit_in(alloc); @@ -395,6 +400,7 @@ impl<T, A: Allocator> Box<T, A> { /// ``` #[unstable(feature = "allocator_api", issue = "32838")] #[cfg(not(no_global_oom_handling))] + #[must_use] // #[unstable(feature = "new_uninit", issue = "63291")] pub fn new_uninit_in(alloc: A) -> Box<mem::MaybeUninit<T>, A> { let layout = Layout::new::<mem::MaybeUninit<T>>(); @@ -459,6 +465,7 @@ impl<T, A: Allocator> Box<T, A> { #[unstable(feature = "allocator_api", issue = "32838")] #[cfg(not(no_global_oom_handling))] // #[unstable(feature = "new_uninit", issue = "63291")] + #[must_use] pub fn new_zeroed_in(alloc: A) -> Box<mem::MaybeUninit<T>, A> { let layout = Layout::new::<mem::MaybeUninit<T>>(); // NOTE: Prefer match over unwrap_or_else since closure sometimes not inlineable. @@ -503,6 +510,7 @@ impl<T, A: Allocator> Box<T, A> { /// `x` will be pinned in memory and unable to be moved. #[cfg(not(no_global_oom_handling))] #[unstable(feature = "allocator_api", issue = "32838")] + #[must_use] #[inline(always)] pub fn pin_in(x: T, alloc: A) -> Pin<Self> where @@ -561,6 +569,7 @@ impl<T> Box<[T]> { /// ``` #[cfg(not(no_global_oom_handling))] #[unstable(feature = "new_uninit", issue = "63291")] + #[must_use] pub fn new_uninit_slice(len: usize) -> Box<[mem::MaybeUninit<T>]> { unsafe { RawVec::with_capacity(len).into_box(len) } } @@ -585,6 +594,7 @@ impl<T> Box<[T]> { /// [zeroed]: mem::MaybeUninit::zeroed #[cfg(not(no_global_oom_handling))] #[unstable(feature = "new_uninit", issue = "63291")] + #[must_use] pub fn new_zeroed_slice(len: usize) -> Box<[mem::MaybeUninit<T>]> { unsafe { RawVec::with_capacity_zeroed(len).into_box(len) } } @@ -681,6 +691,7 @@ impl<T, A: Allocator> Box<[T], A> { #[cfg(not(no_global_oom_handling))] #[unstable(feature = "allocator_api", issue = "32838")] // #[unstable(feature = "new_uninit", issue = "63291")] + #[must_use] pub fn new_uninit_slice_in(len: usize, alloc: A) -> Box<[mem::MaybeUninit<T>], A> { unsafe { RawVec::with_capacity_in(len, alloc).into_box(len) } } @@ -708,6 +719,7 @@ impl<T, A: Allocator> Box<[T], A> { #[cfg(not(no_global_oom_handling))] #[unstable(feature = "allocator_api", issue = "32838")] // #[unstable(feature = "new_uninit", issue = "63291")] + #[must_use] pub fn new_zeroed_slice_in(len: usize, alloc: A) -> Box<[mem::MaybeUninit<T>], A> { unsafe { RawVec::with_capacity_zeroed_in(len, alloc).into_box(len) } } diff --git a/library/alloc/src/collections/binary_heap.rs b/library/alloc/src/collections/binary_heap.rs index 75720a970a3..cfb1cd09c39 100644 --- a/library/alloc/src/collections/binary_heap.rs +++ b/library/alloc/src/collections/binary_heap.rs @@ -364,6 +364,7 @@ impl<T: Ord> BinaryHeap<T> { /// heap.push(4); /// ``` #[stable(feature = "rust1", since = "1.0.0")] + #[must_use] pub fn new() -> BinaryHeap<T> { BinaryHeap { data: vec![] } } @@ -383,6 +384,7 @@ impl<T: Ord> BinaryHeap<T> { /// heap.push(4); /// ``` #[stable(feature = "rust1", since = "1.0.0")] + #[must_use] pub fn with_capacity(capacity: usize) -> BinaryHeap<T> { BinaryHeap { data: Vec::with_capacity(capacity) } } diff --git a/library/alloc/src/collections/btree/map.rs b/library/alloc/src/collections/btree/map.rs index e9265262c8b..fa86e611565 100644 --- a/library/alloc/src/collections/btree/map.rs +++ b/library/alloc/src/collections/btree/map.rs @@ -502,6 +502,7 @@ impl<K, V> BTreeMap<K, V> { /// ``` #[stable(feature = "rust1", since = "1.0.0")] #[rustc_const_unstable(feature = "const_btree_new", issue = "71835")] + #[must_use] pub const fn new() -> BTreeMap<K, V> { BTreeMap { root: None, length: 0 } } diff --git a/library/alloc/src/collections/btree/set.rs b/library/alloc/src/collections/btree/set.rs index f4c10100982..d732f65b0d0 100644 --- a/library/alloc/src/collections/btree/set.rs +++ b/library/alloc/src/collections/btree/set.rs @@ -248,6 +248,7 @@ impl<T> BTreeSet<T> { /// ``` #[stable(feature = "rust1", since = "1.0.0")] #[rustc_const_unstable(feature = "const_btree_new", issue = "71835")] + #[must_use] pub const fn new() -> BTreeSet<T> { BTreeSet { map: BTreeMap::new() } } diff --git a/library/alloc/src/collections/linked_list.rs b/library/alloc/src/collections/linked_list.rs index a769c558b4f..6dcba318c35 100644 --- a/library/alloc/src/collections/linked_list.rs +++ b/library/alloc/src/collections/linked_list.rs @@ -417,6 +417,7 @@ impl<T> LinkedList<T> { #[inline] #[rustc_const_stable(feature = "const_linked_list_new", since = "1.32.0")] #[stable(feature = "rust1", since = "1.0.0")] + #[must_use] pub const fn new() -> Self { LinkedList { head: None, tail: None, len: 0, marker: PhantomData } } diff --git a/library/alloc/src/collections/vec_deque/mod.rs b/library/alloc/src/collections/vec_deque/mod.rs index e996784bbad..09ae1f7eebd 100644 --- a/library/alloc/src/collections/vec_deque/mod.rs +++ b/library/alloc/src/collections/vec_deque/mod.rs @@ -475,6 +475,7 @@ impl<T> VecDeque<T> { /// ``` #[inline] #[stable(feature = "rust1", since = "1.0.0")] + #[must_use] pub fn new() -> VecDeque<T> { VecDeque::new_in(Global) } @@ -490,6 +491,7 @@ impl<T> VecDeque<T> { /// ``` #[inline] #[stable(feature = "rust1", since = "1.0.0")] + #[must_use] pub fn with_capacity(capacity: usize) -> VecDeque<T> { Self::with_capacity_in(capacity, Global) } diff --git a/library/alloc/src/raw_vec.rs b/library/alloc/src/raw_vec.rs index be21018512d..75dbd4678bb 100644 --- a/library/alloc/src/raw_vec.rs +++ b/library/alloc/src/raw_vec.rs @@ -69,6 +69,7 @@ impl<T> RawVec<T, Global> { /// `RawVec` with capacity `0`. If `T` is zero-sized, then it makes a /// `RawVec` with capacity `usize::MAX`. Useful for implementing /// delayed allocation. + #[must_use] pub const fn new() -> Self { Self::new_in(Global) } @@ -87,6 +88,7 @@ impl<T> RawVec<T, Global> { /// /// Aborts on OOM. #[cfg(not(no_global_oom_handling))] + #[must_use] #[inline] pub fn with_capacity(capacity: usize) -> Self { Self::with_capacity_in(capacity, Global) @@ -94,6 +96,7 @@ impl<T> RawVec<T, Global> { /// Like `with_capacity`, but guarantees the buffer is zeroed. #[cfg(not(no_global_oom_handling))] + #[must_use] #[inline] pub fn with_capacity_zeroed(capacity: usize) -> Self { Self::with_capacity_zeroed_in(capacity, Global) diff --git a/library/alloc/src/rc.rs b/library/alloc/src/rc.rs index c6573597b1e..2f4a131136e 100644 --- a/library/alloc/src/rc.rs +++ b/library/alloc/src/rc.rs @@ -452,6 +452,7 @@ impl<T> Rc<T> { /// ``` #[cfg(not(no_global_oom_handling))] #[unstable(feature = "new_uninit", issue = "63291")] + #[must_use] pub fn new_uninit() -> Rc<mem::MaybeUninit<T>> { unsafe { Rc::from_ptr(Rc::allocate_for_layout( @@ -484,6 +485,7 @@ impl<T> Rc<T> { /// [zeroed]: mem::MaybeUninit::zeroed #[cfg(not(no_global_oom_handling))] #[unstable(feature = "new_uninit", issue = "63291")] + #[must_use] pub fn new_zeroed() -> Rc<mem::MaybeUninit<T>> { unsafe { Rc::from_ptr(Rc::allocate_for_layout( @@ -587,6 +589,7 @@ impl<T> Rc<T> { /// `value` will be pinned in memory and unable to be moved. #[cfg(not(no_global_oom_handling))] #[stable(feature = "pin", since = "1.33.0")] + #[must_use] pub fn pin(value: T) -> Pin<Rc<T>> { unsafe { Pin::new_unchecked(Rc::new(value)) } } @@ -658,6 +661,7 @@ impl<T> Rc<[T]> { /// ``` #[cfg(not(no_global_oom_handling))] #[unstable(feature = "new_uninit", issue = "63291")] + #[must_use] pub fn new_uninit_slice(len: usize) -> Rc<[mem::MaybeUninit<T>]> { unsafe { Rc::from_ptr(Rc::allocate_for_slice(len)) } } @@ -684,6 +688,7 @@ impl<T> Rc<[T]> { /// [zeroed]: mem::MaybeUninit::zeroed #[cfg(not(no_global_oom_handling))] #[unstable(feature = "new_uninit", issue = "63291")] + #[must_use] pub fn new_zeroed_slice(len: usize) -> Rc<[mem::MaybeUninit<T>]> { unsafe { Rc::from_ptr(Rc::allocate_for_layout( @@ -2044,6 +2049,7 @@ impl<T> Weak<T> { /// assert!(empty.upgrade().is_none()); /// ``` #[stable(feature = "downgraded_weak", since = "1.10.0")] + #[must_use] pub fn new() -> Weak<T> { Weak { ptr: NonNull::new(usize::MAX as *mut RcBox<T>).expect("MAX is not 0") } } diff --git a/library/alloc/src/str.rs b/library/alloc/src/str.rs index 2900d01d9bd..ac7f2304456 100644 --- a/library/alloc/src/str.rs +++ b/library/alloc/src/str.rs @@ -595,6 +595,7 @@ impl str { /// assert_eq!("☺", &*smile); /// ``` #[stable(feature = "str_box_extras", since = "1.20.0")] +#[must_use] #[inline] pub unsafe fn from_boxed_utf8_unchecked(v: Box<[u8]>) -> Box<str> { unsafe { Box::from_raw(Box::into_raw(v) as *mut str) } diff --git a/library/alloc/src/string.rs b/library/alloc/src/string.rs index d00792b9c3e..f11fa92766f 100644 --- a/library/alloc/src/string.rs +++ b/library/alloc/src/string.rs @@ -378,6 +378,7 @@ impl String { #[inline] #[rustc_const_stable(feature = "const_string_new", since = "1.39.0")] #[stable(feature = "rust1", since = "1.0.0")] + #[must_use] pub const fn new() -> String { String { vec: Vec::new() } } @@ -422,6 +423,7 @@ impl String { #[cfg(not(no_global_oom_handling))] #[inline] #[stable(feature = "rust1", since = "1.0.0")] + #[must_use] pub fn with_capacity(capacity: usize) -> String { String { vec: Vec::with_capacity(capacity) } } @@ -762,6 +764,7 @@ impl String { /// assert_eq!("💖", sparkle_heart); /// ``` #[inline] + #[must_use] #[stable(feature = "rust1", since = "1.0.0")] pub unsafe fn from_utf8_unchecked(bytes: Vec<u8>) -> String { String { vec: bytes } diff --git a/library/alloc/src/sync.rs b/library/alloc/src/sync.rs index 7dd1bc51560..1d4216d7d57 100644 --- a/library/alloc/src/sync.rs +++ b/library/alloc/src/sync.rs @@ -448,6 +448,7 @@ impl<T> Arc<T> { /// ``` #[cfg(not(no_global_oom_handling))] #[unstable(feature = "new_uninit", issue = "63291")] + #[must_use] pub fn new_uninit() -> Arc<mem::MaybeUninit<T>> { unsafe { Arc::from_ptr(Arc::allocate_for_layout( @@ -480,6 +481,7 @@ impl<T> Arc<T> { /// [zeroed]: mem::MaybeUninit::zeroed #[cfg(not(no_global_oom_handling))] #[unstable(feature = "new_uninit", issue = "63291")] + #[must_use] pub fn new_zeroed() -> Arc<mem::MaybeUninit<T>> { unsafe { Arc::from_ptr(Arc::allocate_for_layout( @@ -494,6 +496,7 @@ impl<T> Arc<T> { /// `data` will be pinned in memory and unable to be moved. #[cfg(not(no_global_oom_handling))] #[stable(feature = "pin", since = "1.33.0")] + #[must_use] pub fn pin(data: T) -> Pin<Arc<T>> { unsafe { Pin::new_unchecked(Arc::new(data)) } } @@ -662,6 +665,7 @@ impl<T> Arc<[T]> { /// ``` #[cfg(not(no_global_oom_handling))] #[unstable(feature = "new_uninit", issue = "63291")] + #[must_use] pub fn new_uninit_slice(len: usize) -> Arc<[mem::MaybeUninit<T>]> { unsafe { Arc::from_ptr(Arc::allocate_for_slice(len)) } } @@ -688,6 +692,7 @@ impl<T> Arc<[T]> { /// [zeroed]: mem::MaybeUninit::zeroed #[cfg(not(no_global_oom_handling))] #[unstable(feature = "new_uninit", issue = "63291")] + #[must_use] pub fn new_zeroed_slice(len: usize) -> Arc<[mem::MaybeUninit<T>]> { unsafe { Arc::from_ptr(Arc::allocate_for_layout( @@ -1680,6 +1685,7 @@ impl<T> Weak<T> { /// assert!(empty.upgrade().is_none()); /// ``` #[stable(feature = "downgraded_weak", since = "1.10.0")] + #[must_use] pub fn new() -> Weak<T> { Weak { ptr: NonNull::new(usize::MAX as *mut ArcInner<T>).expect("MAX is not 0") } } diff --git a/library/alloc/src/vec/mod.rs b/library/alloc/src/vec/mod.rs index 4f18a054a0d..a12acb1a1c0 100644 --- a/library/alloc/src/vec/mod.rs +++ b/library/alloc/src/vec/mod.rs @@ -420,6 +420,7 @@ impl<T> Vec<T> { #[inline] #[rustc_const_stable(feature = "const_vec_new", since = "1.39.0")] #[stable(feature = "rust1", since = "1.0.0")] + #[must_use] pub const fn new() -> Self { Vec { buf: RawVec::NEW, len: 0 } } @@ -464,6 +465,7 @@ impl<T> Vec<T> { #[cfg(not(no_global_oom_handling))] #[inline] #[stable(feature = "rust1", since = "1.0.0")] + #[must_use] pub fn with_capacity(capacity: usize) -> Self { Self::with_capacity_in(capacity, Global) } |
