Skip to content

Commit 1067e2c

Browse files
committed
Auto merge of rust-lang#89767 - GuillaumeGomez:rollup-sczixhk, r=GuillaumeGomez
Rollup of 7 pull requests Successful merges: - rust-lang#89655 (bootstrap: don't use `--merges` to look for commit hashes for downloading artifacts) - rust-lang#89726 (Add #[must_use] to alloc constructors) - rust-lang#89729 (Add #[must_use] to core and std constructors) - rust-lang#89743 (Fix RUSTC_LOG handling) - rust-lang#89753 (Add #[must_use] to from_value conversions) - rust-lang#89754 (Cleanup .item-table CSS) - rust-lang#89761 (:arrow_up: rust-analyzer) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents 6ae8912 + 913b1de commit 1067e2c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+144
-9
lines changed

compiler/rustc_driver/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1259,7 +1259,7 @@ pub fn init_env_logger(env: &str) {
12591259
};
12601260

12611261
let filter = match std::env::var(env) {
1262-
Ok(env) => EnvFilter::from_env(env),
1262+
Ok(env) => EnvFilter::new(env),
12631263
_ => EnvFilter::default().add_directive(filter::Directive::from(LevelFilter::WARN)),
12641264
};
12651265

library/alloc/src/boxed.rs

+12
Original file line numberDiff line numberDiff line change
@@ -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
}

library/alloc/src/collections/binary_heap.rs

+2
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,7 @@ impl<T: Ord> BinaryHeap<T> {
364364
/// heap.push(4);
365365
/// ```
366366
#[stable(feature = "rust1", since = "1.0.0")]
367+
#[must_use]
367368
pub fn new() -> BinaryHeap<T> {
368369
BinaryHeap { data: vec![] }
369370
}
@@ -383,6 +384,7 @@ impl<T: Ord> BinaryHeap<T> {
383384
/// heap.push(4);
384385
/// ```
385386
#[stable(feature = "rust1", since = "1.0.0")]
387+
#[must_use]
386388
pub fn with_capacity(capacity: usize) -> BinaryHeap<T> {
387389
BinaryHeap { data: Vec::with_capacity(capacity) }
388390
}

library/alloc/src/collections/btree/map.rs

+1
Original file line numberDiff line numberDiff line change
@@ -502,6 +502,7 @@ impl<K, V> BTreeMap<K, V> {
502502
/// ```
503503
#[stable(feature = "rust1", since = "1.0.0")]
504504
#[rustc_const_unstable(feature = "const_btree_new", issue = "71835")]
505+
#[must_use]
505506
pub const fn new() -> BTreeMap<K, V> {
506507
BTreeMap { root: None, length: 0 }
507508
}

library/alloc/src/collections/btree/set.rs

+1
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,7 @@ impl<T> BTreeSet<T> {
248248
/// ```
249249
#[stable(feature = "rust1", since = "1.0.0")]
250250
#[rustc_const_unstable(feature = "const_btree_new", issue = "71835")]
251+
#[must_use]
251252
pub const fn new() -> BTreeSet<T> {
252253
BTreeSet { map: BTreeMap::new() }
253254
}

library/alloc/src/collections/linked_list.rs

+1
Original file line numberDiff line numberDiff line change
@@ -417,6 +417,7 @@ impl<T> LinkedList<T> {
417417
#[inline]
418418
#[rustc_const_stable(feature = "const_linked_list_new", since = "1.32.0")]
419419
#[stable(feature = "rust1", since = "1.0.0")]
420+
#[must_use]
420421
pub const fn new() -> Self {
421422
LinkedList { head: None, tail: None, len: 0, marker: PhantomData }
422423
}

library/alloc/src/collections/vec_deque/mod.rs

+2
Original file line numberDiff line numberDiff line change
@@ -475,6 +475,7 @@ impl<T> VecDeque<T> {
475475
/// ```
476476
#[inline]
477477
#[stable(feature = "rust1", since = "1.0.0")]
478+
#[must_use]
478479
pub fn new() -> VecDeque<T> {
479480
VecDeque::new_in(Global)
480481
}
@@ -490,6 +491,7 @@ impl<T> VecDeque<T> {
490491
/// ```
491492
#[inline]
492493
#[stable(feature = "rust1", since = "1.0.0")]
494+
#[must_use]
493495
pub fn with_capacity(capacity: usize) -> VecDeque<T> {
494496
Self::with_capacity_in(capacity, Global)
495497
}

library/alloc/src/raw_vec.rs

+3
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ impl<T> RawVec<T, Global> {
6969
/// `RawVec` with capacity `0`. If `T` is zero-sized, then it makes a
7070
/// `RawVec` with capacity `usize::MAX`. Useful for implementing
7171
/// delayed allocation.
72+
#[must_use]
7273
pub const fn new() -> Self {
7374
Self::new_in(Global)
7475
}
@@ -87,13 +88,15 @@ impl<T> RawVec<T, Global> {
8788
///
8889
/// Aborts on OOM.
8990
#[cfg(not(no_global_oom_handling))]
91+
#[must_use]
9092
#[inline]
9193
pub fn with_capacity(capacity: usize) -> Self {
9294
Self::with_capacity_in(capacity, Global)
9395
}
9496

9597
/// Like `with_capacity`, but guarantees the buffer is zeroed.
9698
#[cfg(not(no_global_oom_handling))]
99+
#[must_use]
97100
#[inline]
98101
pub fn with_capacity_zeroed(capacity: usize) -> Self {
99102
Self::with_capacity_zeroed_in(capacity, Global)

library/alloc/src/rc.rs

+6
Original file line numberDiff line numberDiff line change
@@ -452,6 +452,7 @@ impl<T> Rc<T> {
452452
/// ```
453453
#[cfg(not(no_global_oom_handling))]
454454
#[unstable(feature = "new_uninit", issue = "63291")]
455+
#[must_use]
455456
pub fn new_uninit() -> Rc<mem::MaybeUninit<T>> {
456457
unsafe {
457458
Rc::from_ptr(Rc::allocate_for_layout(
@@ -484,6 +485,7 @@ impl<T> Rc<T> {
484485
/// [zeroed]: mem::MaybeUninit::zeroed
485486
#[cfg(not(no_global_oom_handling))]
486487
#[unstable(feature = "new_uninit", issue = "63291")]
488+
#[must_use]
487489
pub fn new_zeroed() -> Rc<mem::MaybeUninit<T>> {
488490
unsafe {
489491
Rc::from_ptr(Rc::allocate_for_layout(
@@ -587,6 +589,7 @@ impl<T> Rc<T> {
587589
/// `value` will be pinned in memory and unable to be moved.
588590
#[cfg(not(no_global_oom_handling))]
589591
#[stable(feature = "pin", since = "1.33.0")]
592+
#[must_use]
590593
pub fn pin(value: T) -> Pin<Rc<T>> {
591594
unsafe { Pin::new_unchecked(Rc::new(value)) }
592595
}
@@ -658,6 +661,7 @@ impl<T> Rc<[T]> {
658661
/// ```
659662
#[cfg(not(no_global_oom_handling))]
660663
#[unstable(feature = "new_uninit", issue = "63291")]
664+
#[must_use]
661665
pub fn new_uninit_slice(len: usize) -> Rc<[mem::MaybeUninit<T>]> {
662666
unsafe { Rc::from_ptr(Rc::allocate_for_slice(len)) }
663667
}
@@ -684,6 +688,7 @@ impl<T> Rc<[T]> {
684688
/// [zeroed]: mem::MaybeUninit::zeroed
685689
#[cfg(not(no_global_oom_handling))]
686690
#[unstable(feature = "new_uninit", issue = "63291")]
691+
#[must_use]
687692
pub fn new_zeroed_slice(len: usize) -> Rc<[mem::MaybeUninit<T>]> {
688693
unsafe {
689694
Rc::from_ptr(Rc::allocate_for_layout(
@@ -2044,6 +2049,7 @@ impl<T> Weak<T> {
20442049
/// assert!(empty.upgrade().is_none());
20452050
/// ```
20462051
#[stable(feature = "downgraded_weak", since = "1.10.0")]
2052+
#[must_use]
20472053
pub fn new() -> Weak<T> {
20482054
Weak { ptr: NonNull::new(usize::MAX as *mut RcBox<T>).expect("MAX is not 0") }
20492055
}

library/alloc/src/str.rs

+1
Original file line numberDiff line numberDiff line change
@@ -595,6 +595,7 @@ impl str {
595595
/// assert_eq!("☺", &*smile);
596596
/// ```
597597
#[stable(feature = "str_box_extras", since = "1.20.0")]
598+
#[must_use]
598599
#[inline]
599600
pub unsafe fn from_boxed_utf8_unchecked(v: Box<[u8]>) -> Box<str> {
600601
unsafe { Box::from_raw(Box::into_raw(v) as *mut str) }

library/alloc/src/string.rs

+3
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,7 @@ impl String {
378378
#[inline]
379379
#[rustc_const_stable(feature = "const_string_new", since = "1.39.0")]
380380
#[stable(feature = "rust1", since = "1.0.0")]
381+
#[must_use]
381382
pub const fn new() -> String {
382383
String { vec: Vec::new() }
383384
}
@@ -422,6 +423,7 @@ impl String {
422423
#[cfg(not(no_global_oom_handling))]
423424
#[inline]
424425
#[stable(feature = "rust1", since = "1.0.0")]
426+
#[must_use]
425427
pub fn with_capacity(capacity: usize) -> String {
426428
String { vec: Vec::with_capacity(capacity) }
427429
}
@@ -762,6 +764,7 @@ impl String {
762764
/// assert_eq!("💖", sparkle_heart);
763765
/// ```
764766
#[inline]
767+
#[must_use]
765768
#[stable(feature = "rust1", since = "1.0.0")]
766769
pub unsafe fn from_utf8_unchecked(bytes: Vec<u8>) -> String {
767770
String { vec: bytes }

library/alloc/src/sync.rs

+6
Original file line numberDiff line numberDiff line change
@@ -448,6 +448,7 @@ impl<T> Arc<T> {
448448
/// ```
449449
#[cfg(not(no_global_oom_handling))]
450450
#[unstable(feature = "new_uninit", issue = "63291")]
451+
#[must_use]
451452
pub fn new_uninit() -> Arc<mem::MaybeUninit<T>> {
452453
unsafe {
453454
Arc::from_ptr(Arc::allocate_for_layout(
@@ -480,6 +481,7 @@ impl<T> Arc<T> {
480481
/// [zeroed]: mem::MaybeUninit::zeroed
481482
#[cfg(not(no_global_oom_handling))]
482483
#[unstable(feature = "new_uninit", issue = "63291")]
484+
#[must_use]
483485
pub fn new_zeroed() -> Arc<mem::MaybeUninit<T>> {
484486
unsafe {
485487
Arc::from_ptr(Arc::allocate_for_layout(
@@ -494,6 +496,7 @@ impl<T> Arc<T> {
494496
/// `data` will be pinned in memory and unable to be moved.
495497
#[cfg(not(no_global_oom_handling))]
496498
#[stable(feature = "pin", since = "1.33.0")]
499+
#[must_use]
497500
pub fn pin(data: T) -> Pin<Arc<T>> {
498501
unsafe { Pin::new_unchecked(Arc::new(data)) }
499502
}
@@ -662,6 +665,7 @@ impl<T> Arc<[T]> {
662665
/// ```
663666
#[cfg(not(no_global_oom_handling))]
664667
#[unstable(feature = "new_uninit", issue = "63291")]
668+
#[must_use]
665669
pub fn new_uninit_slice(len: usize) -> Arc<[mem::MaybeUninit<T>]> {
666670
unsafe { Arc::from_ptr(Arc::allocate_for_slice(len)) }
667671
}
@@ -688,6 +692,7 @@ impl<T> Arc<[T]> {
688692
/// [zeroed]: mem::MaybeUninit::zeroed
689693
#[cfg(not(no_global_oom_handling))]
690694
#[unstable(feature = "new_uninit", issue = "63291")]
695+
#[must_use]
691696
pub fn new_zeroed_slice(len: usize) -> Arc<[mem::MaybeUninit<T>]> {
692697
unsafe {
693698
Arc::from_ptr(Arc::allocate_for_layout(
@@ -1680,6 +1685,7 @@ impl<T> Weak<T> {
16801685
/// assert!(empty.upgrade().is_none());
16811686
/// ```
16821687
#[stable(feature = "downgraded_weak", since = "1.10.0")]
1688+
#[must_use]
16831689
pub fn new() -> Weak<T> {
16841690
Weak { ptr: NonNull::new(usize::MAX as *mut ArcInner<T>).expect("MAX is not 0") }
16851691
}

library/alloc/src/vec/mod.rs

+2
Original file line numberDiff line numberDiff line change
@@ -420,6 +420,7 @@ impl<T> Vec<T> {
420420
#[inline]
421421
#[rustc_const_stable(feature = "const_vec_new", since = "1.39.0")]
422422
#[stable(feature = "rust1", since = "1.0.0")]
423+
#[must_use]
423424
pub const fn new() -> Self {
424425
Vec { buf: RawVec::NEW, len: 0 }
425426
}
@@ -464,6 +465,7 @@ impl<T> Vec<T> {
464465
#[cfg(not(no_global_oom_handling))]
465466
#[inline]
466467
#[stable(feature = "rust1", since = "1.0.0")]
468+
#[must_use]
467469
pub fn with_capacity(capacity: usize) -> Self {
468470
Self::with_capacity_in(capacity, Global)
469471
}

library/core/src/alloc/layout.rs

+2
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ impl Layout {
9494
/// [`Layout::from_size_align`].
9595
#[stable(feature = "alloc_layout", since = "1.28.0")]
9696
#[rustc_const_stable(feature = "alloc_layout", since = "1.36.0")]
97+
#[must_use]
9798
#[inline]
9899
pub const unsafe fn from_size_align_unchecked(size: usize, align: usize) -> Self {
99100
// SAFETY: the caller must ensure that `align` is greater than zero.
@@ -119,6 +120,7 @@ impl Layout {
119120
/// Constructs a `Layout` suitable for holding a value of type `T`.
120121
#[stable(feature = "alloc_layout", since = "1.28.0")]
121122
#[rustc_const_stable(feature = "alloc_layout_const_new", since = "1.42.0")]
123+
#[must_use]
122124
#[inline]
123125
pub const fn new<T>() -> Self {
124126
let (size, align) = size_align::<T>();

library/core/src/char/convert.rs

+3
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ use super::MAX;
4848
/// assert_eq!(None, c);
4949
/// ```
5050
#[doc(alias = "chr")]
51+
#[must_use]
5152
#[inline]
5253
#[stable(feature = "rust1", since = "1.0.0")]
5354
pub fn from_u32(i: u32) -> Option<char> {
@@ -88,6 +89,7 @@ pub fn from_u32(i: u32) -> Option<char> {
8889
/// assert_eq!('❤', c);
8990
/// ```
9091
#[inline]
92+
#[must_use]
9193
#[stable(feature = "char_from_unchecked", since = "1.5.0")]
9294
pub unsafe fn from_u32_unchecked(i: u32) -> char {
9395
// SAFETY: the caller must guarantee that `i` is a valid char value.
@@ -319,6 +321,7 @@ impl fmt::Display for CharTryFromError {
319321
/// let c = char::from_digit(1, 37);
320322
/// ```
321323
#[inline]
324+
#[must_use]
322325
#[stable(feature = "rust1", since = "1.0.0")]
323326
pub fn from_digit(num: u32, radix: u32) -> Option<char> {
324327
if radix > 36 {

library/core/src/char/methods.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ impl char {
136136
/// assert_eq!(None, c);
137137
/// ```
138138
#[stable(feature = "assoc_char_funcs", since = "1.52.0")]
139+
#[must_use]
139140
#[inline]
140141
pub fn from_u32(i: u32) -> Option<char> {
141142
super::convert::from_u32(i)
@@ -177,6 +178,7 @@ impl char {
177178
/// assert_eq!('❤', c);
178179
/// ```
179180
#[stable(feature = "assoc_char_funcs", since = "1.52.0")]
181+
#[must_use]
180182
#[inline]
181183
pub unsafe fn from_u32_unchecked(i: u32) -> char {
182184
// SAFETY: the safety contract must be upheld by the caller.
@@ -230,9 +232,10 @@ impl char {
230232
/// use std::char;
231233
///
232234
/// // this panics
233-
/// char::from_digit(1, 37);
235+
/// let _c = char::from_digit(1, 37);
234236
/// ```
235237
#[stable(feature = "assoc_char_funcs", since = "1.52.0")]
238+
#[must_use]
236239
#[inline]
237240
pub fn from_digit(num: u32, radix: u32) -> Option<char> {
238241
super::convert::from_digit(num, radix)

0 commit comments

Comments
 (0)