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 (⬆️ rust-analyzer) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
This commit is contained in:
commit
1067e2ca5e
@ -1259,7 +1259,7 @@ pub fn init_env_logger(env: &str) {
|
||||
};
|
||||
|
||||
let filter = match std::env::var(env) {
|
||||
Ok(env) => EnvFilter::from_env(env),
|
||||
Ok(env) => EnvFilter::new(env),
|
||||
_ => EnvFilter::default().add_directive(filter::Directive::from(LevelFilter::WARN)),
|
||||
};
|
||||
|
||||
|
@ -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 @@ pub fn new(x: T) -> Self {
|
||||
/// ```
|
||||
#[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 @@ pub fn new_uninit() -> Box<mem::MaybeUninit<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 @@ pub fn new_zeroed() -> Box<mem::MaybeUninit<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 @@ pub fn try_new_in(x: T, alloc: A) -> Result<Self, AllocError> {
|
||||
/// ```
|
||||
#[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 @@ pub fn try_new_uninit_in(alloc: A) -> Result<Box<mem::MaybeUninit<T>, A>, AllocE
|
||||
#[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 @@ pub fn try_new_zeroed_in(alloc: A) -> Result<Box<mem::MaybeUninit<T>, A>, AllocE
|
||||
/// `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 @@ pub fn new_uninit_slice(len: usize) -> Box<[mem::MaybeUninit<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 @@ pub fn new_uninit_slice_in(len: usize, alloc: A) -> Box<[mem::MaybeUninit<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) }
|
||||
}
|
||||
|
@ -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 @@ pub fn new() -> 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) }
|
||||
}
|
||||
|
@ -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 }
|
||||
}
|
||||
|
@ -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() }
|
||||
}
|
||||
|
@ -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 }
|
||||
}
|
||||
|
@ -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 @@ pub fn new() -> 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)
|
||||
}
|
||||
|
@ -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 @@ pub const fn new() -> Self {
|
||||
///
|
||||
/// 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 @@ pub fn with_capacity(capacity: usize) -> Self {
|
||||
|
||||
/// 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)
|
||||
|
@ -452,6 +452,7 @@ pub fn new_cyclic(data_fn: impl FnOnce(&Weak<T>) -> 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 @@ pub fn new_uninit() -> Rc<mem::MaybeUninit<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 @@ pub fn try_new_zeroed() -> Result<Rc<mem::MaybeUninit<T>>, AllocError> {
|
||||
/// `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 @@ pub fn new_uninit_slice(len: usize) -> Rc<[mem::MaybeUninit<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") }
|
||||
}
|
||||
|
@ -595,6 +595,7 @@ pub fn to_ascii_lowercase(&self) -> String {
|
||||
/// 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) }
|
||||
|
@ -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 @@ pub const fn new() -> 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 @@ pub unsafe fn from_raw_parts(buf: *mut u8, length: usize, capacity: usize) -> St
|
||||
/// 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 }
|
||||
|
@ -448,6 +448,7 @@ pub fn new_cyclic(data_fn: impl FnOnce(&Weak<T>) -> 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 @@ pub fn new_uninit() -> Arc<mem::MaybeUninit<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 @@ pub fn new_zeroed() -> Arc<mem::MaybeUninit<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 @@ pub fn new_uninit_slice(len: usize) -> Arc<[mem::MaybeUninit<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") }
|
||||
}
|
||||
|
@ -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 @@ pub const fn new() -> Self {
|
||||
#[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)
|
||||
}
|
||||
|
@ -94,6 +94,7 @@ pub const fn from_size_align(size: usize, align: usize) -> Result<Self, LayoutEr
|
||||
/// [`Layout::from_size_align`].
|
||||
#[stable(feature = "alloc_layout", since = "1.28.0")]
|
||||
#[rustc_const_stable(feature = "alloc_layout", since = "1.36.0")]
|
||||
#[must_use]
|
||||
#[inline]
|
||||
pub const unsafe fn from_size_align_unchecked(size: usize, align: usize) -> Self {
|
||||
// SAFETY: the caller must ensure that `align` is greater than zero.
|
||||
@ -119,6 +120,7 @@ pub const fn align(&self) -> usize {
|
||||
/// Constructs a `Layout` suitable for holding a value of type `T`.
|
||||
#[stable(feature = "alloc_layout", since = "1.28.0")]
|
||||
#[rustc_const_stable(feature = "alloc_layout_const_new", since = "1.42.0")]
|
||||
#[must_use]
|
||||
#[inline]
|
||||
pub const fn new<T>() -> Self {
|
||||
let (size, align) = size_align::<T>();
|
||||
|
@ -48,6 +48,7 @@
|
||||
/// assert_eq!(None, c);
|
||||
/// ```
|
||||
#[doc(alias = "chr")]
|
||||
#[must_use]
|
||||
#[inline]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
pub fn from_u32(i: u32) -> Option<char> {
|
||||
@ -88,6 +89,7 @@ pub fn from_u32(i: u32) -> Option<char> {
|
||||
/// assert_eq!('❤', c);
|
||||
/// ```
|
||||
#[inline]
|
||||
#[must_use]
|
||||
#[stable(feature = "char_from_unchecked", since = "1.5.0")]
|
||||
pub unsafe fn from_u32_unchecked(i: u32) -> char {
|
||||
// SAFETY: the caller must guarantee that `i` is a valid char value.
|
||||
@ -319,6 +321,7 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
/// let c = char::from_digit(1, 37);
|
||||
/// ```
|
||||
#[inline]
|
||||
#[must_use]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
pub fn from_digit(num: u32, radix: u32) -> Option<char> {
|
||||
if radix > 36 {
|
||||
|
@ -136,6 +136,7 @@ pub fn decode_utf16<I: IntoIterator<Item = u16>>(iter: I) -> DecodeUtf16<I::Into
|
||||
/// assert_eq!(None, c);
|
||||
/// ```
|
||||
#[stable(feature = "assoc_char_funcs", since = "1.52.0")]
|
||||
#[must_use]
|
||||
#[inline]
|
||||
pub fn from_u32(i: u32) -> Option<char> {
|
||||
super::convert::from_u32(i)
|
||||
@ -177,6 +178,7 @@ pub fn from_u32(i: u32) -> Option<char> {
|
||||
/// assert_eq!('❤', c);
|
||||
/// ```
|
||||
#[stable(feature = "assoc_char_funcs", since = "1.52.0")]
|
||||
#[must_use]
|
||||
#[inline]
|
||||
pub unsafe fn from_u32_unchecked(i: u32) -> char {
|
||||
// SAFETY: the safety contract must be upheld by the caller.
|
||||
@ -230,9 +232,10 @@ pub unsafe fn from_u32_unchecked(i: u32) -> char {
|
||||
/// use std::char;
|
||||
///
|
||||
/// // this panics
|
||||
/// char::from_digit(1, 37);
|
||||
/// let _c = char::from_digit(1, 37);
|
||||
/// ```
|
||||
#[stable(feature = "assoc_char_funcs", since = "1.52.0")]
|
||||
#[must_use]
|
||||
#[inline]
|
||||
pub fn from_digit(num: u32, radix: u32) -> Option<char> {
|
||||
super::convert::from_digit(num, radix)
|
||||
|
@ -157,6 +157,7 @@ impl SipHasher {
|
||||
since = "1.13.0",
|
||||
reason = "use `std::collections::hash_map::DefaultHasher` instead"
|
||||
)]
|
||||
#[must_use]
|
||||
pub fn new() -> SipHasher {
|
||||
SipHasher::new_with_keys(0, 0)
|
||||
}
|
||||
@ -168,6 +169,7 @@ pub fn new() -> SipHasher {
|
||||
since = "1.13.0",
|
||||
reason = "use `std::collections::hash_map::DefaultHasher` instead"
|
||||
)]
|
||||
#[must_use]
|
||||
pub fn new_with_keys(key0: u64, key1: u64) -> SipHasher {
|
||||
SipHasher(SipHasher24 { hasher: Hasher::new_with_keys(key0, key1) })
|
||||
}
|
||||
|
@ -83,6 +83,7 @@ fn from(value: T) -> Self {
|
||||
impl<T> OnceCell<T> {
|
||||
/// Creates a new empty cell.
|
||||
#[unstable(feature = "once_cell", issue = "74465")]
|
||||
#[must_use]
|
||||
pub const fn new() -> OnceCell<T> {
|
||||
OnceCell { inner: UnsafeCell::new(None) }
|
||||
}
|
||||
|
@ -312,6 +312,7 @@ pub const fn new(val: T) -> MaybeUninit<T> {
|
||||
/// ```
|
||||
#[stable(feature = "maybe_uninit", since = "1.36.0")]
|
||||
#[rustc_const_stable(feature = "const_maybe_uninit", since = "1.36.0")]
|
||||
#[must_use]
|
||||
#[inline(always)]
|
||||
#[rustc_diagnostic_item = "maybe_uninit_uninit"]
|
||||
pub const fn uninit() -> MaybeUninit<T> {
|
||||
@ -349,6 +350,7 @@ pub const fn uninit() -> MaybeUninit<T> {
|
||||
/// ```
|
||||
#[unstable(feature = "maybe_uninit_uninit_array", issue = "none")]
|
||||
#[rustc_const_unstable(feature = "maybe_uninit_uninit_array", issue = "none")]
|
||||
#[must_use]
|
||||
#[inline(always)]
|
||||
pub const fn uninit_array<const LEN: usize>() -> [Self; LEN] {
|
||||
// SAFETY: An uninitialized `[MaybeUninit<_>; LEN]` is valid.
|
||||
@ -391,6 +393,7 @@ pub const fn uninit() -> MaybeUninit<T> {
|
||||
/// // This is undefined behavior. ⚠️
|
||||
/// ```
|
||||
#[stable(feature = "maybe_uninit", since = "1.36.0")]
|
||||
#[must_use]
|
||||
#[inline]
|
||||
#[rustc_diagnostic_item = "maybe_uninit_zeroed"]
|
||||
pub fn zeroed() -> MaybeUninit<T> {
|
||||
|
@ -801,6 +801,7 @@ pub const fn to_bits(self) -> u32 {
|
||||
/// ```
|
||||
#[stable(feature = "float_bits_conv", since = "1.20.0")]
|
||||
#[rustc_const_unstable(feature = "const_float_bits_conv", issue = "72447")]
|
||||
#[must_use]
|
||||
#[inline]
|
||||
pub const fn from_bits(v: u32) -> Self {
|
||||
// SAFETY: `u32` is a plain old datatype so we can always transmute from it
|
||||
@ -885,6 +886,7 @@ pub const fn from_bits(v: u32) -> Self {
|
||||
/// ```
|
||||
#[stable(feature = "float_to_from_bytes", since = "1.40.0")]
|
||||
#[rustc_const_unstable(feature = "const_float_bits_conv", issue = "72447")]
|
||||
#[must_use]
|
||||
#[inline]
|
||||
pub const fn from_be_bytes(bytes: [u8; 4]) -> Self {
|
||||
Self::from_bits(u32::from_be_bytes(bytes))
|
||||
@ -900,6 +902,7 @@ pub const fn from_bits(v: u32) -> Self {
|
||||
/// ```
|
||||
#[stable(feature = "float_to_from_bytes", since = "1.40.0")]
|
||||
#[rustc_const_unstable(feature = "const_float_bits_conv", issue = "72447")]
|
||||
#[must_use]
|
||||
#[inline]
|
||||
pub const fn from_le_bytes(bytes: [u8; 4]) -> Self {
|
||||
Self::from_bits(u32::from_le_bytes(bytes))
|
||||
@ -926,6 +929,7 @@ pub const fn from_bits(v: u32) -> Self {
|
||||
/// ```
|
||||
#[stable(feature = "float_to_from_bytes", since = "1.40.0")]
|
||||
#[rustc_const_unstable(feature = "const_float_bits_conv", issue = "72447")]
|
||||
#[must_use]
|
||||
#[inline]
|
||||
pub const fn from_ne_bytes(bytes: [u8; 4]) -> Self {
|
||||
Self::from_bits(u32::from_ne_bytes(bytes))
|
||||
|
@ -817,6 +817,7 @@ pub const fn to_bits(self) -> u64 {
|
||||
/// ```
|
||||
#[stable(feature = "float_bits_conv", since = "1.20.0")]
|
||||
#[rustc_const_unstable(feature = "const_float_bits_conv", issue = "72447")]
|
||||
#[must_use]
|
||||
#[inline]
|
||||
pub const fn from_bits(v: u64) -> Self {
|
||||
// SAFETY: `u64` is a plain old datatype so we can always transmute from it
|
||||
@ -901,6 +902,7 @@ pub const fn from_bits(v: u64) -> Self {
|
||||
/// ```
|
||||
#[stable(feature = "float_to_from_bytes", since = "1.40.0")]
|
||||
#[rustc_const_unstable(feature = "const_float_bits_conv", issue = "72447")]
|
||||
#[must_use]
|
||||
#[inline]
|
||||
pub const fn from_be_bytes(bytes: [u8; 8]) -> Self {
|
||||
Self::from_bits(u64::from_be_bytes(bytes))
|
||||
@ -916,6 +918,7 @@ pub const fn from_bits(v: u64) -> Self {
|
||||
/// ```
|
||||
#[stable(feature = "float_to_from_bytes", since = "1.40.0")]
|
||||
#[rustc_const_unstable(feature = "const_float_bits_conv", issue = "72447")]
|
||||
#[must_use]
|
||||
#[inline]
|
||||
pub const fn from_le_bytes(bytes: [u8; 8]) -> Self {
|
||||
Self::from_bits(u64::from_le_bytes(bytes))
|
||||
@ -942,6 +945,7 @@ pub const fn from_bits(v: u64) -> Self {
|
||||
/// ```
|
||||
#[stable(feature = "float_to_from_bytes", since = "1.40.0")]
|
||||
#[rustc_const_unstable(feature = "const_float_bits_conv", issue = "72447")]
|
||||
#[must_use]
|
||||
#[inline]
|
||||
pub const fn from_ne_bytes(bytes: [u8; 8]) -> Self {
|
||||
Self::from_bits(u64::from_ne_bytes(bytes))
|
||||
|
@ -297,6 +297,7 @@ pub const fn reverse_bits(self) -> Self {
|
||||
/// ```
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[rustc_const_stable(feature = "const_int_conversions", since = "1.32.0")]
|
||||
#[must_use]
|
||||
#[inline]
|
||||
pub const fn from_be(x: Self) -> Self {
|
||||
#[cfg(target_endian = "big")]
|
||||
@ -328,6 +329,7 @@ pub const fn from_be(x: Self) -> Self {
|
||||
/// ```
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[rustc_const_stable(feature = "const_int_conversions", since = "1.32.0")]
|
||||
#[must_use]
|
||||
#[inline]
|
||||
pub const fn from_le(x: Self) -> Self {
|
||||
#[cfg(target_endian = "little")]
|
||||
@ -2671,6 +2673,7 @@ pub const fn is_negative(self) -> bool { self < 0 }
|
||||
/// ```
|
||||
#[stable(feature = "int_to_from_bytes", since = "1.32.0")]
|
||||
#[rustc_const_stable(feature = "const_int_conversion", since = "1.44.0")]
|
||||
#[must_use]
|
||||
#[inline]
|
||||
pub const fn from_be_bytes(bytes: [u8; mem::size_of::<Self>()]) -> Self {
|
||||
Self::from_be(Self::from_ne_bytes(bytes))
|
||||
@ -2701,6 +2704,7 @@ pub const fn is_negative(self) -> bool { self < 0 }
|
||||
/// ```
|
||||
#[stable(feature = "int_to_from_bytes", since = "1.32.0")]
|
||||
#[rustc_const_stable(feature = "const_int_conversion", since = "1.44.0")]
|
||||
#[must_use]
|
||||
#[inline]
|
||||
pub const fn from_le_bytes(bytes: [u8; mem::size_of::<Self>()]) -> Self {
|
||||
Self::from_le(Self::from_ne_bytes(bytes))
|
||||
@ -2742,6 +2746,7 @@ pub const fn is_negative(self) -> bool { self < 0 }
|
||||
/// ```
|
||||
#[stable(feature = "int_to_from_bytes", since = "1.32.0")]
|
||||
#[rustc_const_stable(feature = "const_int_conversion", since = "1.44.0")]
|
||||
#[must_use]
|
||||
// SAFETY: const sound because integers are plain old datatypes so we can always
|
||||
// transmute to them
|
||||
#[inline]
|
||||
|
@ -50,6 +50,7 @@ impl $Ty {
|
||||
/// The value must not be zero.
|
||||
#[$stability]
|
||||
#[$const_new_unchecked_stability]
|
||||
#[must_use]
|
||||
#[inline]
|
||||
pub const unsafe fn new_unchecked(n: $Int) -> Self {
|
||||
// SAFETY: this is guaranteed to be safe by the caller.
|
||||
@ -59,6 +60,7 @@ impl $Ty {
|
||||
/// Creates a non-zero if the given value is not zero.
|
||||
#[$stability]
|
||||
#[rustc_const_stable(feature = "const_nonzero_int_methods", since = "1.47.0")]
|
||||
#[must_use]
|
||||
#[inline]
|
||||
pub const fn new(n: $Int) -> Option<Self> {
|
||||
if n != 0 {
|
||||
|
@ -657,6 +657,7 @@ pub const fn reverse_bits(self) -> Self {
|
||||
/// }
|
||||
/// ```
|
||||
#[inline]
|
||||
#[must_use]
|
||||
#[unstable(feature = "saturating_int_impl", issue = "87920")]
|
||||
pub const fn from_be(x: Self) -> Self {
|
||||
Saturating(<$t>::from_be(x.0))
|
||||
@ -684,6 +685,7 @@ pub const fn from_be(x: Self) -> Self {
|
||||
/// }
|
||||
/// ```
|
||||
#[inline]
|
||||
#[must_use]
|
||||
#[unstable(feature = "saturating_int_impl", issue = "87920")]
|
||||
pub const fn from_le(x: Self) -> Self {
|
||||
Saturating(<$t>::from_le(x.0))
|
||||
|
@ -300,6 +300,7 @@ pub const fn reverse_bits(self) -> Self {
|
||||
/// ```
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[rustc_const_stable(feature = "const_math", since = "1.32.0")]
|
||||
#[must_use]
|
||||
#[inline(always)]
|
||||
pub const fn from_be(x: Self) -> Self {
|
||||
#[cfg(target_endian = "big")]
|
||||
@ -332,6 +333,7 @@ pub const fn from_be(x: Self) -> Self {
|
||||
/// ```
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[rustc_const_stable(feature = "const_math", since = "1.32.0")]
|
||||
#[must_use]
|
||||
#[inline(always)]
|
||||
pub const fn from_le(x: Self) -> Self {
|
||||
#[cfg(target_endian = "little")]
|
||||
@ -2321,6 +2323,7 @@ pub const fn wrapping_next_power_of_two(self) -> Self {
|
||||
/// ```
|
||||
#[stable(feature = "int_to_from_bytes", since = "1.32.0")]
|
||||
#[rustc_const_stable(feature = "const_int_conversion", since = "1.44.0")]
|
||||
#[must_use]
|
||||
#[inline]
|
||||
pub const fn from_be_bytes(bytes: [u8; mem::size_of::<Self>()]) -> Self {
|
||||
Self::from_be(Self::from_ne_bytes(bytes))
|
||||
@ -2351,6 +2354,7 @@ pub const fn wrapping_next_power_of_two(self) -> Self {
|
||||
/// ```
|
||||
#[stable(feature = "int_to_from_bytes", since = "1.32.0")]
|
||||
#[rustc_const_stable(feature = "const_int_conversion", since = "1.44.0")]
|
||||
#[must_use]
|
||||
#[inline]
|
||||
pub const fn from_le_bytes(bytes: [u8; mem::size_of::<Self>()]) -> Self {
|
||||
Self::from_le(Self::from_ne_bytes(bytes))
|
||||
@ -2392,6 +2396,7 @@ pub const fn wrapping_next_power_of_two(self) -> Self {
|
||||
/// ```
|
||||
#[stable(feature = "int_to_from_bytes", since = "1.32.0")]
|
||||
#[rustc_const_stable(feature = "const_int_conversion", since = "1.44.0")]
|
||||
#[must_use]
|
||||
// SAFETY: const sound because integers are plain old datatypes so we can always
|
||||
// transmute to them
|
||||
#[inline]
|
||||
|
@ -651,6 +651,7 @@ pub const fn reverse_bits(self) -> Self {
|
||||
/// }
|
||||
/// ```
|
||||
#[inline]
|
||||
#[must_use]
|
||||
#[unstable(feature = "wrapping_int_impl", issue = "32463")]
|
||||
pub const fn from_be(x: Self) -> Self {
|
||||
Wrapping(<$t>::from_be(x.0))
|
||||
@ -678,6 +679,7 @@ pub const fn from_be(x: Self) -> Self {
|
||||
/// }
|
||||
/// ```
|
||||
#[inline]
|
||||
#[must_use]
|
||||
#[unstable(feature = "wrapping_int_impl", issue = "32463")]
|
||||
pub const fn from_le(x: Self) -> Self {
|
||||
Wrapping(<$t>::from_le(x.0))
|
||||
|
@ -155,6 +155,7 @@ pub fn from_utf8_mut(v: &mut [u8]) -> Result<&mut str, Utf8Error> {
|
||||
/// assert_eq!("💖", sparkle_heart);
|
||||
/// ```
|
||||
#[inline]
|
||||
#[must_use]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[rustc_const_stable(feature = "const_str_from_utf8_unchecked", since = "1.55.0")]
|
||||
pub const unsafe fn from_utf8_unchecked(v: &[u8]) -> &str {
|
||||
@ -181,6 +182,7 @@ pub fn from_utf8_mut(v: &mut [u8]) -> Result<&mut str, Utf8Error> {
|
||||
/// assert_eq!("💖", heart);
|
||||
/// ```
|
||||
#[inline]
|
||||
#[must_use]
|
||||
#[stable(feature = "str_mut_extras", since = "1.20.0")]
|
||||
pub unsafe fn from_utf8_unchecked_mut(v: &mut [u8]) -> &mut str {
|
||||
// SAFETY: the caller must guarantee that the bytes `v`
|
||||
|
@ -12,10 +12,12 @@ pub struct Utf8Lossy {
|
||||
}
|
||||
|
||||
impl Utf8Lossy {
|
||||
#[must_use]
|
||||
pub fn from_str(s: &str) -> &Utf8Lossy {
|
||||
Utf8Lossy::from_bytes(s.as_bytes())
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn from_bytes(bytes: &[u8]) -> &Utf8Lossy {
|
||||
// SAFETY: Both use the same memory layout, and UTF-8 correctness isn't required.
|
||||
unsafe { mem::transmute(bytes) }
|
||||
|
@ -290,6 +290,7 @@ impl AtomicBool {
|
||||
#[inline]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[rustc_const_stable(feature = "const_atomic_new", since = "1.24.0")]
|
||||
#[must_use]
|
||||
pub const fn new(v: bool) -> AtomicBool {
|
||||
AtomicBool { v: UnsafeCell::new(v as u8) }
|
||||
}
|
||||
@ -1392,6 +1393,7 @@ impl $atomic_type {
|
||||
#[inline]
|
||||
#[$stable]
|
||||
#[$const_stable]
|
||||
#[must_use]
|
||||
pub const fn new(v: $int_type) -> Self {
|
||||
Self {v: UnsafeCell::new(v)}
|
||||
}
|
||||
|
@ -39,6 +39,7 @@ impl RawWaker {
|
||||
#[rustc_promotable]
|
||||
#[stable(feature = "futures_api", since = "1.36.0")]
|
||||
#[rustc_const_stable(feature = "futures_api", since = "1.36.0")]
|
||||
#[must_use]
|
||||
pub const fn new(data: *const (), vtable: &'static RawWakerVTable) -> RawWaker {
|
||||
RawWaker { data, vtable }
|
||||
}
|
||||
@ -158,6 +159,7 @@ pub struct Context<'a> {
|
||||
impl<'a> Context<'a> {
|
||||
/// Create a new `Context` from a `&Waker`.
|
||||
#[stable(feature = "futures_api", since = "1.36.0")]
|
||||
#[must_use]
|
||||
#[inline]
|
||||
pub fn from_waker(waker: &'a Waker) -> Self {
|
||||
Context { waker, _marker: PhantomData }
|
||||
@ -251,6 +253,7 @@ pub fn will_wake(&self, other: &Waker) -> bool {
|
||||
/// in [`RawWaker`]'s and [`RawWakerVTable`]'s documentation is not upheld.
|
||||
/// Therefore this method is unsafe.
|
||||
#[inline]
|
||||
#[must_use]
|
||||
#[stable(feature = "futures_api", since = "1.36.0")]
|
||||
pub unsafe fn from_raw(waker: RawWaker) -> Waker {
|
||||
Waker { waker }
|
||||
|
@ -181,6 +181,7 @@ impl Duration {
|
||||
#[stable(feature = "duration", since = "1.3.0")]
|
||||
#[inline]
|
||||
#[rustc_const_unstable(feature = "duration_consts_2", issue = "72440")]
|
||||
#[must_use]
|
||||
pub const fn new(secs: u64, nanos: u32) -> Duration {
|
||||
let secs = match secs.checked_add((nanos / NANOS_PER_SEC) as u64) {
|
||||
Some(secs) => secs,
|
||||
@ -203,6 +204,7 @@ pub const fn new(secs: u64, nanos: u32) -> Duration {
|
||||
/// assert_eq!(0, duration.subsec_nanos());
|
||||
/// ```
|
||||
#[stable(feature = "duration", since = "1.3.0")]
|
||||
#[must_use]
|
||||
#[inline]
|
||||
#[rustc_const_stable(feature = "duration_consts", since = "1.32.0")]
|
||||
pub const fn from_secs(secs: u64) -> Duration {
|
||||
@ -222,6 +224,7 @@ pub const fn from_secs(secs: u64) -> Duration {
|
||||
/// assert_eq!(569_000_000, duration.subsec_nanos());
|
||||
/// ```
|
||||
#[stable(feature = "duration", since = "1.3.0")]
|
||||
#[must_use]
|
||||
#[inline]
|
||||
#[rustc_const_stable(feature = "duration_consts", since = "1.32.0")]
|
||||
pub const fn from_millis(millis: u64) -> Duration {
|
||||
@ -244,6 +247,7 @@ pub const fn from_millis(millis: u64) -> Duration {
|
||||
/// assert_eq!(2000, duration.subsec_nanos());
|
||||
/// ```
|
||||
#[stable(feature = "duration_from_micros", since = "1.27.0")]
|
||||
#[must_use]
|
||||
#[inline]
|
||||
#[rustc_const_stable(feature = "duration_consts", since = "1.32.0")]
|
||||
pub const fn from_micros(micros: u64) -> Duration {
|
||||
@ -266,6 +270,7 @@ pub const fn from_micros(micros: u64) -> Duration {
|
||||
/// assert_eq!(123, duration.subsec_nanos());
|
||||
/// ```
|
||||
#[stable(feature = "duration_extras", since = "1.27.0")]
|
||||
#[must_use]
|
||||
#[inline]
|
||||
#[rustc_const_stable(feature = "duration_consts", since = "1.32.0")]
|
||||
pub const fn from_nanos(nanos: u64) -> Duration {
|
||||
@ -707,6 +712,7 @@ pub const fn as_secs_f32(&self) -> f32 {
|
||||
/// assert_eq!(dur, Duration::new(2, 700_000_000));
|
||||
/// ```
|
||||
#[stable(feature = "duration_float", since = "1.38.0")]
|
||||
#[must_use]
|
||||
#[inline]
|
||||
#[rustc_const_unstable(feature = "duration_consts_2", issue = "72440")]
|
||||
pub const fn from_secs_f64(secs: f64) -> Duration {
|
||||
@ -768,6 +774,7 @@ pub const fn try_from_secs_f64(secs: f64) -> Result<Duration, FromSecsError> {
|
||||
/// assert_eq!(dur, Duration::new(2, 700_000_000));
|
||||
/// ```
|
||||
#[stable(feature = "duration_float", since = "1.38.0")]
|
||||
#[must_use]
|
||||
#[inline]
|
||||
#[rustc_const_unstable(feature = "duration_consts_2", issue = "72440")]
|
||||
pub const fn from_secs_f32(secs: f32) -> Duration {
|
||||
|
@ -223,6 +223,7 @@ impl<K, V> HashMap<K, V, RandomState> {
|
||||
/// let mut map: HashMap<&str, i32> = HashMap::new();
|
||||
/// ```
|
||||
#[inline]
|
||||
#[must_use]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
pub fn new() -> HashMap<K, V, RandomState> {
|
||||
Default::default()
|
||||
@ -240,6 +241,7 @@ pub fn new() -> HashMap<K, V, RandomState> {
|
||||
/// let mut map: HashMap<&str, i32> = HashMap::with_capacity(10);
|
||||
/// ```
|
||||
#[inline]
|
||||
#[must_use]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
pub fn with_capacity(capacity: usize) -> HashMap<K, V, RandomState> {
|
||||
HashMap::with_capacity_and_hasher(capacity, Default::default())
|
||||
@ -2894,6 +2896,7 @@ impl RandomState {
|
||||
#[inline]
|
||||
#[allow(deprecated)]
|
||||
// rand
|
||||
#[must_use]
|
||||
#[stable(feature = "hashmap_build_hasher", since = "1.7.0")]
|
||||
pub fn new() -> RandomState {
|
||||
// Historically this function did not cache keys from the OS and instead
|
||||
@ -2946,6 +2949,7 @@ impl DefaultHasher {
|
||||
/// instances created through `new` or `default`.
|
||||
#[stable(feature = "hashmap_default_hasher", since = "1.13.0")]
|
||||
#[allow(deprecated)]
|
||||
#[must_use]
|
||||
pub fn new() -> DefaultHasher {
|
||||
DefaultHasher(SipHasher13::new_with_keys(0, 0))
|
||||
}
|
||||
|
@ -126,6 +126,7 @@ impl<T> HashSet<T, RandomState> {
|
||||
/// let set: HashSet<i32> = HashSet::new();
|
||||
/// ```
|
||||
#[inline]
|
||||
#[must_use]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
pub fn new() -> HashSet<T, RandomState> {
|
||||
Default::default()
|
||||
@ -144,6 +145,7 @@ pub fn new() -> HashSet<T, RandomState> {
|
||||
/// assert!(set.capacity() >= 10);
|
||||
/// ```
|
||||
#[inline]
|
||||
#[must_use]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
pub fn with_capacity(capacity: usize) -> HashSet<T, RandomState> {
|
||||
HashSet { base: base::HashSet::with_capacity_and_hasher(capacity, Default::default()) }
|
||||
|
@ -426,6 +426,7 @@ fn _new(bytes: Vec<u8>) -> Result<CString, NulError> {
|
||||
/// let c_string = CString::from_vec_unchecked(raw);
|
||||
/// }
|
||||
/// ```
|
||||
#[must_use]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
pub unsafe fn from_vec_unchecked(mut v: Vec<u8>) -> CString {
|
||||
v.reserve_exact(1);
|
||||
@ -477,6 +478,7 @@ pub unsafe fn from_vec_unchecked(mut v: Vec<u8>) -> CString {
|
||||
/// let c_string = CString::from_raw(raw);
|
||||
/// }
|
||||
/// ```
|
||||
#[must_use = "call `drop(from_raw(ptr))` if you intend to drop the `CString`"]
|
||||
#[stable(feature = "cstr_memory", since = "1.4.0")]
|
||||
pub unsafe fn from_raw(ptr: *mut c_char) -> CString {
|
||||
// SAFETY: This is called with a pointer that was obtained from a call
|
||||
@ -705,6 +707,7 @@ fn into_inner(self) -> Box<[u8]> {
|
||||
/// unsafe { CString::from_vec_unchecked(b"abc".to_vec()) }
|
||||
/// );
|
||||
/// ```
|
||||
#[must_use]
|
||||
#[unstable(feature = "cstring_from_vec_with_nul", issue = "73179")]
|
||||
pub unsafe fn from_vec_with_nul_unchecked(v: Vec<u8>) -> Self {
|
||||
Self { inner: v.into_boxed_slice() }
|
||||
@ -1168,6 +1171,7 @@ impl CStr {
|
||||
/// }
|
||||
/// # }
|
||||
/// ```
|
||||
#[must_use]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
pub unsafe fn from_ptr<'a>(ptr: *const c_char) -> &'a CStr {
|
||||
// SAFETY: The caller has provided a pointer that points to a valid C
|
||||
@ -1250,6 +1254,7 @@ pub fn from_bytes_with_nul(bytes: &[u8]) -> Result<&CStr, FromBytesWithNulError>
|
||||
/// }
|
||||
/// ```
|
||||
#[inline]
|
||||
#[must_use]
|
||||
#[stable(feature = "cstr_from_bytes", since = "1.10.0")]
|
||||
#[rustc_const_unstable(feature = "const_cstr_unchecked", issue = "none")]
|
||||
pub const unsafe fn from_bytes_with_nul_unchecked(bytes: &[u8]) -> &CStr {
|
||||
|
@ -119,6 +119,7 @@ impl OsString {
|
||||
/// let os_string = OsString::new();
|
||||
/// ```
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[must_use]
|
||||
#[inline]
|
||||
pub fn new() -> OsString {
|
||||
OsString { inner: Buf::from_string(String::new()) }
|
||||
@ -199,6 +200,7 @@ pub fn push<T: AsRef<OsStr>>(&mut self, s: T) {
|
||||
/// assert_eq!(capacity, os_string.capacity());
|
||||
/// ```
|
||||
#[stable(feature = "osstring_simple_functions", since = "1.9.0")]
|
||||
#[must_use]
|
||||
#[inline]
|
||||
pub fn with_capacity(capacity: usize) -> OsString {
|
||||
OsString { inner: Buf::with_capacity(capacity) }
|
||||
|
@ -744,6 +744,7 @@ impl OpenOptions {
|
||||
/// let file = options.read(true).open("foo.txt");
|
||||
/// ```
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[must_use]
|
||||
pub fn new() -> Self {
|
||||
OpenOptions(fs_imp::OpenOptions::new())
|
||||
}
|
||||
@ -2184,6 +2185,7 @@ impl DirBuilder {
|
||||
/// let builder = DirBuilder::new();
|
||||
/// ```
|
||||
#[stable(feature = "dir_builder", since = "1.6.0")]
|
||||
#[must_use]
|
||||
pub fn new() -> DirBuilder {
|
||||
DirBuilder { inner: fs_imp::DirBuilder::new(), recursive: false }
|
||||
}
|
||||
|
@ -473,6 +473,7 @@ pub fn last_os_error() -> Error {
|
||||
/// # }
|
||||
/// ```
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[must_use]
|
||||
#[inline]
|
||||
pub fn from_raw_os_error(code: i32) -> Error {
|
||||
Error { repr: Repr::Os(code) }
|
||||
|
@ -1206,6 +1206,7 @@ impl<'a> IoSlice<'a> {
|
||||
///
|
||||
/// Panics on Windows if the slice is larger than 4GB.
|
||||
#[stable(feature = "iovec", since = "1.36.0")]
|
||||
#[must_use]
|
||||
#[inline]
|
||||
pub fn new(buf: &'a [u8]) -> IoSlice<'a> {
|
||||
IoSlice(sys::io::IoSlice::new(buf))
|
||||
|
@ -171,6 +171,7 @@ impl<T: Eq> Eq for SyncOnceCell<T> {}
|
||||
impl<T> SyncOnceCell<T> {
|
||||
/// Creates a new empty cell.
|
||||
#[unstable(feature = "once_cell", issue = "74465")]
|
||||
#[must_use]
|
||||
pub const fn new() -> SyncOnceCell<T> {
|
||||
SyncOnceCell {
|
||||
once: Once::new(),
|
||||
|
@ -131,6 +131,7 @@ impl SocketAddr {
|
||||
/// assert_eq!(socket.port(), 8080);
|
||||
/// ```
|
||||
#[stable(feature = "ip_addr", since = "1.7.0")]
|
||||
#[must_use]
|
||||
pub fn new(ip: IpAddr, port: u16) -> SocketAddr {
|
||||
match ip {
|
||||
IpAddr::V4(a) => SocketAddr::V4(SocketAddrV4::new(a, port)),
|
||||
@ -272,6 +273,7 @@ impl SocketAddrV4 {
|
||||
/// let socket = SocketAddrV4::new(Ipv4Addr::new(127, 0, 0, 1), 8080);
|
||||
/// ```
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[must_use]
|
||||
pub fn new(ip: Ipv4Addr, port: u16) -> SocketAddrV4 {
|
||||
SocketAddrV4 {
|
||||
inner: c::sockaddr_in {
|
||||
@ -368,6 +370,7 @@ impl SocketAddrV6 {
|
||||
/// let socket = SocketAddrV6::new(Ipv6Addr::new(0, 0, 0, 0, 0, 0, 0, 1), 8080, 0, 0);
|
||||
/// ```
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[must_use]
|
||||
pub fn new(ip: Ipv6Addr, port: u16, flowinfo: u32, scope_id: u32) -> SocketAddrV6 {
|
||||
SocketAddrV6 {
|
||||
inner: c::sockaddr_in6 {
|
||||
|
@ -442,6 +442,7 @@ impl Ipv4Addr {
|
||||
/// ```
|
||||
#[rustc_const_stable(feature = "const_ipv4", since = "1.32.0")]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[must_use]
|
||||
#[inline]
|
||||
pub const fn new(a: u8, b: u8, c: u8, d: u8) -> Ipv4Addr {
|
||||
// `s_addr` is stored as BE on all machine and the array is in BE order.
|
||||
@ -1192,6 +1193,7 @@ impl Ipv6Addr {
|
||||
/// ```
|
||||
#[rustc_const_stable(feature = "const_ipv6", since = "1.32.0")]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[must_use]
|
||||
#[inline]
|
||||
pub const fn new(a: u16, b: u16, c: u16, d: u16, e: u16, f: u16, g: u16, h: u16) -> Ipv6Addr {
|
||||
let addr16 = [
|
||||
|
@ -189,6 +189,7 @@ impl SocketCred {
|
||||
///
|
||||
/// PID, UID and GID is set to 0.
|
||||
#[unstable(feature = "unix_socket_ancillary_data", issue = "76915")]
|
||||
#[must_use]
|
||||
pub fn new() -> SocketCred {
|
||||
SocketCred(libc::ucred { pid: 0, uid: 0, gid: 0 })
|
||||
}
|
||||
|
@ -1146,6 +1146,7 @@ fn as_mut_vec(&mut self) -> &mut Vec<u8> {
|
||||
/// let path = PathBuf::new();
|
||||
/// ```
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[must_use]
|
||||
#[inline]
|
||||
pub fn new() -> PathBuf {
|
||||
PathBuf { inner: OsString::new() }
|
||||
@ -1170,6 +1171,7 @@ pub fn new() -> PathBuf {
|
||||
///
|
||||
/// [`with_capacity`]: OsString::with_capacity
|
||||
#[stable(feature = "path_buf_capacity", since = "1.44.0")]
|
||||
#[must_use]
|
||||
#[inline]
|
||||
pub fn with_capacity(capacity: usize) -> PathBuf {
|
||||
PathBuf { inner: OsString::with_capacity(capacity) }
|
||||
|
@ -80,6 +80,7 @@ impl Barrier {
|
||||
/// let barrier = Barrier::new(10);
|
||||
/// ```
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[must_use]
|
||||
pub fn new(n: usize) -> Barrier {
|
||||
Barrier {
|
||||
lock: Mutex::new(BarrierState { count: 0, generation_id: 0 }),
|
||||
|
@ -121,6 +121,7 @@ impl Condvar {
|
||||
/// let condvar = Condvar::new();
|
||||
/// ```
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[must_use]
|
||||
pub fn new() -> Condvar {
|
||||
Condvar { inner: sys::Condvar::new() }
|
||||
}
|
||||
|
@ -186,6 +186,7 @@ impl Once {
|
||||
#[inline]
|
||||
#[stable(feature = "once_new", since = "1.2.0")]
|
||||
#[rustc_const_stable(feature = "const_once_new", since = "1.32.0")]
|
||||
#[must_use]
|
||||
pub const fn new() -> Once {
|
||||
Once { state_and_queue: AtomicUsize::new(INCOMPLETE), _marker: marker::PhantomData }
|
||||
}
|
||||
|
@ -460,7 +460,7 @@ class RustBuild(object):
|
||||
# LLVM more often than necessary.
|
||||
#
|
||||
# This git command finds that commit SHA, looking for bors-authored
|
||||
# merges that modified src/llvm-project or other relevant version
|
||||
# commits that modified src/llvm-project or other relevant version
|
||||
# stamp files.
|
||||
#
|
||||
# This works even in a repository that has not yet initialized
|
||||
@ -470,7 +470,7 @@ class RustBuild(object):
|
||||
]).decode(sys.getdefaultencoding()).strip()
|
||||
llvm_sha = subprocess.check_output([
|
||||
"git", "rev-list", "--author=bors@rust-lang.org", "-n1",
|
||||
"--merges", "--first-parent", "HEAD",
|
||||
"--first-parent", "HEAD",
|
||||
"--",
|
||||
"{}/src/llvm-project".format(top_level),
|
||||
"{}/src/bootstrap/download-ci-llvm-stamp".format(top_level),
|
||||
@ -540,6 +540,12 @@ class RustBuild(object):
|
||||
unpack(tarball, tarball_suffix, self.bin_root(stage0), match=pattern, verbose=self.verbose)
|
||||
|
||||
def _download_ci_llvm(self, llvm_sha, llvm_assertions):
|
||||
if not llvm_sha:
|
||||
print("error: could not find commit hash for downloading LLVM")
|
||||
print("help: maybe your repository history is too shallow?")
|
||||
print("help: consider disabling `download-ci-llvm`")
|
||||
print("help: or fetch enough history to include one upstream commit")
|
||||
exit(1)
|
||||
cache_prefix = "llvm-{}-{}".format(llvm_sha, llvm_assertions)
|
||||
cache_dst = os.path.join(self.build_dir, "cache")
|
||||
rustc_cache = os.path.join(cache_dst, cache_prefix)
|
||||
@ -685,9 +691,15 @@ class RustBuild(object):
|
||||
# Only commits merged by bors will have CI artifacts.
|
||||
merge_base = [
|
||||
"git", "rev-list", "--author=bors@rust-lang.org", "-n1",
|
||||
"--merges", "--first-parent", "HEAD"
|
||||
"--first-parent", "HEAD"
|
||||
]
|
||||
commit = subprocess.check_output(merge_base, universal_newlines=True).strip()
|
||||
if not commit:
|
||||
print("error: could not find commit hash for downloading rustc")
|
||||
print("help: maybe your repository history is too shallow?")
|
||||
print("help: consider disabling `download-rustc`")
|
||||
print("help: or fetch enough history to include one upstream commit")
|
||||
exit(1)
|
||||
|
||||
# Warn if there were changes to the compiler or standard library since the ancestor commit.
|
||||
status = subprocess.call(["git", "diff-index", "--quiet", commit, "--", compiler, library])
|
||||
|
@ -772,7 +772,7 @@ h2.small-section-header > .anchor {
|
||||
.block a.current.crate { font-weight: 500; }
|
||||
|
||||
.item-table {
|
||||
display: table-row;
|
||||
display: table;
|
||||
}
|
||||
.item-row {
|
||||
display: table-row;
|
||||
|
@ -2,6 +2,6 @@
|
||||
|
||||
fn main() {
|
||||
enum Void {}
|
||||
std::rc::Weak::<Void>::new();
|
||||
std::sync::Weak::<Void>::new();
|
||||
let _ = std::rc::Weak::<Void>::new();
|
||||
let _ = std::sync::Weak::<Void>::new();
|
||||
}
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit 4b7675fcc30d3e2c05eafc68a5724db66b58142c
|
||||
Subproject commit ed4b312fa777ebb39ba1348fe3df574c441a485e
|
Loading…
Reference in New Issue
Block a user