diff --git a/compiler/rustc_data_structures/src/tagged_ptr/copy.rs b/compiler/rustc_data_structures/src/tagged_ptr/copy.rs index 8af4042ad875b..ff4208def319d 100644 --- a/compiler/rustc_data_structures/src/tagged_ptr/copy.rs +++ b/compiler/rustc_data_structures/src/tagged_ptr/copy.rs @@ -143,15 +143,14 @@ where // `{non_zero} | packed_tag` can't make the value zero. let packed = (addr.get() >> T::BITS) | packed_tag; - unsafe { NonZero::::new_unchecked(packed) } + unsafe { NonZero::new_unchecked(packed) } }) } /// Retrieves the original raw pointer from `self.packed`. #[inline] pub(super) fn pointer_raw(&self) -> NonNull { - self.packed - .map_addr(|addr| unsafe { NonZero::::new_unchecked(addr.get() << T::BITS) }) + self.packed.map_addr(|addr| unsafe { NonZero::new_unchecked(addr.get() << T::BITS) }) } /// This provides a reference to the `P` pointer itself, rather than the diff --git a/compiler/rustc_feature/src/lib.rs b/compiler/rustc_feature/src/lib.rs index 02ce5d3534c43..cbc0ce8c97468 100644 --- a/compiler/rustc_feature/src/lib.rs +++ b/compiler/rustc_feature/src/lib.rs @@ -105,7 +105,7 @@ const fn to_nonzero(n: Option) -> Option> { // in const context. Requires https://github.com/rust-lang/rfcs/pull/2632. match n { None => None, - Some(n) => NonZero::::new(n), + Some(n) => NonZero::new(n), } } diff --git a/compiler/rustc_interface/src/tests.rs b/compiler/rustc_interface/src/tests.rs index a9c614df7adef..112553b2f7031 100644 --- a/compiler/rustc_interface/src/tests.rs +++ b/compiler/rustc_interface/src/tests.rs @@ -827,7 +827,7 @@ fn test_unstable_options_tracking_hash() { tracked!(tls_model, Some(TlsModel::GeneralDynamic)); tracked!(translate_remapped_path_to_local_path, false); tracked!(trap_unreachable, Some(false)); - tracked!(treat_err_as_bug, NonZero::::new(1)); + tracked!(treat_err_as_bug, NonZero::new(1)); tracked!(tune_cpu, Some(String::from("abc"))); tracked!(uninit_const_chunk_threshold, 123); tracked!(unleash_the_miri_inside_of_you, true); diff --git a/compiler/rustc_interface/src/util.rs b/compiler/rustc_interface/src/util.rs index 00cf84138bac6..087c43075f175 100644 --- a/compiler/rustc_interface/src/util.rs +++ b/compiler/rustc_interface/src/util.rs @@ -107,7 +107,7 @@ pub(crate) fn run_in_thread_pool_with_globals R + Send, R: Send>( use rustc_query_impl::QueryCtxt; use rustc_query_system::query::{deadlock, QueryContext}; - let registry = sync::Registry::new(std::num::NonZero::::new(threads).unwrap()); + let registry = sync::Registry::new(std::num::NonZero::new(threads).unwrap()); if !sync::is_dyn_thread_safe() { return run_in_thread_with_globals(edition, || { diff --git a/compiler/rustc_metadata/src/rmeta/decoder.rs b/compiler/rustc_metadata/src/rmeta/decoder.rs index 8a031e4f3a301..13d2af7a78e9b 100644 --- a/compiler/rustc_metadata/src/rmeta/decoder.rs +++ b/compiler/rustc_metadata/src/rmeta/decoder.rs @@ -338,7 +338,7 @@ impl<'a, 'tcx> DecodeContext<'a, 'tcx> { } LazyState::Previous(last_pos) => last_pos.get() + distance, }; - let position = NonZero::::new(position).unwrap(); + let position = NonZero::new(position).unwrap(); self.lazy_state = LazyState::Previous(position); f(position) } @@ -685,17 +685,15 @@ impl MetadataBlob { } pub(crate) fn get_rustc_version(&self) -> String { - LazyValue::::from_position( - NonZero::::new(METADATA_HEADER.len() + 8).unwrap(), - ) - .decode(self) + LazyValue::::from_position(NonZero::new(METADATA_HEADER.len() + 8).unwrap()) + .decode(self) } fn root_pos(&self) -> NonZero { let offset = METADATA_HEADER.len(); let pos_bytes = self.blob()[offset..][..8].try_into().unwrap(); let pos = u64::from_le_bytes(pos_bytes); - NonZero::::new(pos as usize).unwrap() + NonZero::new(pos as usize).unwrap() } pub(crate) fn get_header(&self) -> CrateHeader { diff --git a/compiler/rustc_metadata/src/rmeta/encoder.rs b/compiler/rustc_metadata/src/rmeta/encoder.rs index 51d747efdd36b..b25f215c1aaae 100644 --- a/compiler/rustc_metadata/src/rmeta/encoder.rs +++ b/compiler/rustc_metadata/src/rmeta/encoder.rs @@ -439,7 +439,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> { position.get() - last_pos.get() } }; - self.lazy_state = LazyState::Previous(NonZero::::new(pos).unwrap()); + self.lazy_state = LazyState::Previous(NonZero::new(pos).unwrap()); self.emit_usize(distance); } @@ -447,7 +447,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> { where T::Value<'tcx>: Encodable>, { - let pos = NonZero::::new(self.position()).unwrap(); + let pos = NonZero::new(self.position()).unwrap(); assert_eq!(self.lazy_state, LazyState::NoNode); self.lazy_state = LazyState::NodeStart(pos); @@ -466,7 +466,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> { where T::Value<'tcx>: Encodable>, { - let pos = NonZero::::new(self.position()).unwrap(); + let pos = NonZero::new(self.position()).unwrap(); assert_eq!(self.lazy_state, LazyState::NoNode); self.lazy_state = LazyState::NodeStart(pos); diff --git a/compiler/rustc_metadata/src/rmeta/mod.rs b/compiler/rustc_metadata/src/rmeta/mod.rs index 81d834e0456a5..7c145cb5f82ad 100644 --- a/compiler/rustc_metadata/src/rmeta/mod.rs +++ b/compiler/rustc_metadata/src/rmeta/mod.rs @@ -119,7 +119,7 @@ impl ParameterizedOverTcx for LazyArray { impl Default for LazyArray { fn default() -> LazyArray { - LazyArray::from_position_and_num_elems(NonZero::::new(1).unwrap(), 0) + LazyArray::from_position_and_num_elems(NonZero::new(1).unwrap(), 0) } } diff --git a/compiler/rustc_metadata/src/rmeta/table.rs b/compiler/rustc_metadata/src/rmeta/table.rs index 00752ad15a33a..c5f281964df02 100644 --- a/compiler/rustc_metadata/src/rmeta/table.rs +++ b/compiler/rustc_metadata/src/rmeta/table.rs @@ -339,7 +339,7 @@ impl FixedSizeEncoding for Option> { #[inline] fn from_bytes(b: &[u8; 8]) -> Self { - let position = NonZero::::new(u64::from_bytes(b) as usize)?; + let position = NonZero::new(u64::from_bytes(b) as usize)?; Some(LazyValue::from_position(position)) } @@ -366,7 +366,7 @@ impl LazyArray { } fn from_bytes_impl(position: &[u8; 8], meta: &[u8; 8]) -> Option> { - let position = NonZero::::new(u64::from_bytes(position) as usize)?; + let position = NonZero::new(u64::from_bytes(position) as usize)?; let len = u64::from_bytes(meta) as usize; Some(LazyArray::from_position_and_num_elems(position, len)) } @@ -497,7 +497,7 @@ impl> TableBui } LazyTable::from_position_and_encoded_size( - NonZero::::new(pos).unwrap(), + NonZero::new(pos).unwrap(), width, self.blocks.len(), ) diff --git a/compiler/rustc_middle/src/middle/stability.rs b/compiler/rustc_middle/src/middle/stability.rs index 15ef00629b986..2f624ab052710 100644 --- a/compiler/rustc_middle/src/middle/stability.rs +++ b/compiler/rustc_middle/src/middle/stability.rs @@ -433,7 +433,7 @@ impl<'tcx> TyCtxt<'tcx> { // the `-Z force-unstable-if-unmarked` flag present (we're // compiling a compiler crate), then let this missing feature // annotation slide. - if feature == sym::rustc_private && issue == NonZero::::new(27812) { + if feature == sym::rustc_private && issue == NonZero::new(27812) { if self.sess.opts.unstable_opts.force_unstable_if_unmarked { return EvalResult::Allow; } diff --git a/compiler/rustc_middle/src/mir/interpret/mod.rs b/compiler/rustc_middle/src/mir/interpret/mod.rs index 4ef02a86e30e2..903c83cc54e51 100644 --- a/compiler/rustc_middle/src/mir/interpret/mod.rs +++ b/compiler/rustc_middle/src/mir/interpret/mod.rs @@ -500,7 +500,7 @@ impl<'tcx> AllocMap<'tcx> { AllocMap { alloc_map: Default::default(), dedup: Default::default(), - next_id: AllocId(NonZero::::new(1).unwrap()), + next_id: AllocId(NonZero::new(1).unwrap()), } } fn reserve(&mut self) -> AllocId { diff --git a/compiler/rustc_middle/src/mir/interpret/pointer.rs b/compiler/rustc_middle/src/mir/interpret/pointer.rs index 15e12c456793b..e2767ee298958 100644 --- a/compiler/rustc_middle/src/mir/interpret/pointer.rs +++ b/compiler/rustc_middle/src/mir/interpret/pointer.rs @@ -155,7 +155,7 @@ impl CtfeProvenance { /// Returns the `AllocId` of this provenance. #[inline(always)] pub fn alloc_id(self) -> AllocId { - AllocId(NonZero::::new(self.0.get() & !IMMUTABLE_MASK).unwrap()) + AllocId(NonZero::new(self.0.get() & !IMMUTABLE_MASK).unwrap()) } /// Returns whether this provenance is immutable. diff --git a/compiler/rustc_middle/src/ty/consts/int.rs b/compiler/rustc_middle/src/ty/consts/int.rs index 15f69d2333c73..5d50510338c61 100644 --- a/compiler/rustc_middle/src/ty/consts/int.rs +++ b/compiler/rustc_middle/src/ty/consts/int.rs @@ -161,14 +161,14 @@ impl Decodable for ScalarInt { let mut data = [0u8; 16]; let size = d.read_u8(); data[..size as usize].copy_from_slice(d.read_raw_bytes(size as usize)); - ScalarInt { data: u128::from_le_bytes(data), size: NonZero::::new(size).unwrap() } + ScalarInt { data: u128::from_le_bytes(data), size: NonZero::new(size).unwrap() } } } impl ScalarInt { - pub const TRUE: ScalarInt = ScalarInt { data: 1_u128, size: NonZero::::new(1).unwrap() }; + pub const TRUE: ScalarInt = ScalarInt { data: 1_u128, size: NonZero::new(1).unwrap() }; - pub const FALSE: ScalarInt = ScalarInt { data: 0_u128, size: NonZero::::new(1).unwrap() }; + pub const FALSE: ScalarInt = ScalarInt { data: 0_u128, size: NonZero::new(1).unwrap() }; #[inline] pub fn size(self) -> Size { @@ -196,7 +196,7 @@ impl ScalarInt { #[inline] pub fn null(size: Size) -> Self { - Self { data: 0, size: NonZero::::new(size.bytes() as u8).unwrap() } + Self { data: 0, size: NonZero::new(size.bytes() as u8).unwrap() } } #[inline] @@ -208,7 +208,7 @@ impl ScalarInt { pub fn try_from_uint(i: impl Into, size: Size) -> Option { let data = i.into(); if size.truncate(data) == data { - Some(Self { data, size: NonZero::::new(size.bytes() as u8).unwrap() }) + Some(Self { data, size: NonZero::new(size.bytes() as u8).unwrap() }) } else { None } @@ -220,7 +220,7 @@ impl ScalarInt { // `into` performed sign extension, we have to truncate let truncated = size.truncate(i as u128); if size.sign_extend(truncated) as i128 == i { - Some(Self { data: truncated, size: NonZero::::new(size.bytes() as u8).unwrap() }) + Some(Self { data: truncated, size: NonZero::new(size.bytes() as u8).unwrap() }) } else { None } @@ -388,7 +388,7 @@ macro_rules! from { fn from(u: $ty) -> Self { Self { data: u128::from(u), - size: NonZero::::new(std::mem::size_of::<$ty>() as u8).unwrap(), + size: NonZero::new(std::mem::size_of::<$ty>() as u8).unwrap(), } } } @@ -427,10 +427,7 @@ impl TryFrom for bool { impl From for ScalarInt { #[inline] fn from(c: char) -> Self { - Self { - data: c as u128, - size: NonZero::::new(std::mem::size_of::() as u8).unwrap(), - } + Self { data: c as u128, size: NonZero::new(std::mem::size_of::() as u8).unwrap() } } } @@ -457,7 +454,7 @@ impl From for ScalarInt { #[inline] fn from(f: Single) -> Self { // We trust apfloat to give us properly truncated data. - Self { data: f.to_bits(), size: NonZero::::new((Single::BITS / 8) as u8).unwrap() } + Self { data: f.to_bits(), size: NonZero::new((Single::BITS / 8) as u8).unwrap() } } } @@ -473,7 +470,7 @@ impl From for ScalarInt { #[inline] fn from(f: Double) -> Self { // We trust apfloat to give us properly truncated data. - Self { data: f.to_bits(), size: NonZero::::new((Double::BITS / 8) as u8).unwrap() } + Self { data: f.to_bits(), size: NonZero::new((Double::BITS / 8) as u8).unwrap() } } } diff --git a/compiler/rustc_middle/src/ty/generic_args.rs b/compiler/rustc_middle/src/ty/generic_args.rs index c931c2064b0c5..813a7a64daf00 100644 --- a/compiler/rustc_middle/src/ty/generic_args.rs +++ b/compiler/rustc_middle/src/ty/generic_args.rs @@ -143,9 +143,8 @@ impl<'tcx> From> for GenericArg<'tcx> { impl<'tcx> GenericArg<'tcx> { #[inline] pub fn unpack(self) -> GenericArgKind<'tcx> { - let ptr = unsafe { - self.ptr.map_addr(|addr| NonZero::::new_unchecked(addr.get() & !TAG_MASK)) - }; + let ptr = + unsafe { self.ptr.map_addr(|addr| NonZero::new_unchecked(addr.get() & !TAG_MASK)) }; // SAFETY: use of `Interned::new_unchecked` here is ok because these // pointers were originally created from `Interned` types in `pack()`, // and this is just going in the other direction. diff --git a/compiler/rustc_middle/src/ty/layout.rs b/compiler/rustc_middle/src/ty/layout.rs index d9fa99535b1b5..2b34f5daaf63f 100644 --- a/compiler/rustc_middle/src/ty/layout.rs +++ b/compiler/rustc_middle/src/ty/layout.rs @@ -761,7 +761,7 @@ where }; tcx.mk_layout(LayoutS { variants: Variants::Single { index: variant_index }, - fields: match NonZero::::new(fields) { + fields: match NonZero::new(fields) { Some(fields) => FieldsShape::Union(fields), None => FieldsShape::Arbitrary { offsets: IndexVec::new(), memory_index: IndexVec::new() }, }, diff --git a/compiler/rustc_middle/src/ty/mod.rs b/compiler/rustc_middle/src/ty/mod.rs index 3eea0d428eeb9..eea3624898c8c 100644 --- a/compiler/rustc_middle/src/ty/mod.rs +++ b/compiler/rustc_middle/src/ty/mod.rs @@ -617,9 +617,8 @@ impl<'tcx, D: TyDecoder>> Decodable for Term<'tcx> { impl<'tcx> Term<'tcx> { #[inline] pub fn unpack(self) -> TermKind<'tcx> { - let ptr = unsafe { - self.ptr.map_addr(|addr| NonZero::::new_unchecked(addr.get() & !TAG_MASK)) - }; + let ptr = + unsafe { self.ptr.map_addr(|addr| NonZero::new_unchecked(addr.get() & !TAG_MASK)) }; // SAFETY: use of `Interned::new_unchecked` here is ok because these // pointers were originally created from `Interned` types in `pack()`, // and this is just going in the other direction. diff --git a/compiler/rustc_passes/src/stability.rs b/compiler/rustc_passes/src/stability.rs index 312a136c897c6..19272b52b32e6 100644 --- a/compiler/rustc_passes/src/stability.rs +++ b/compiler/rustc_passes/src/stability.rs @@ -645,7 +645,7 @@ fn stability_index(tcx: TyCtxt<'_>, (): ()) -> Index { let stability = Stability { level: attr::StabilityLevel::Unstable { reason: UnstableReason::Default, - issue: NonZero::::new(27812), + issue: NonZero::new(27812), is_soft: false, implied_by: None, }, diff --git a/compiler/rustc_query_impl/src/plumbing.rs b/compiler/rustc_query_impl/src/plumbing.rs index 8cbcce986a1a3..5917d79983d02 100644 --- a/compiler/rustc_query_impl/src/plumbing.rs +++ b/compiler/rustc_query_impl/src/plumbing.rs @@ -68,10 +68,8 @@ impl QueryContext for QueryCtxt<'_> { #[inline] fn next_job_id(self) -> QueryJobId { QueryJobId( - NonZero::::new( - self.query_system.jobs.fetch_add(1, std::sync::atomic::Ordering::Relaxed), - ) - .unwrap(), + NonZero::new(self.query_system.jobs.fetch_add(1, std::sync::atomic::Ordering::Relaxed)) + .unwrap(), ) } diff --git a/compiler/rustc_serialize/src/serialize.rs b/compiler/rustc_serialize/src/serialize.rs index a38a4a916fb82..412f7eced433c 100644 --- a/compiler/rustc_serialize/src/serialize.rs +++ b/compiler/rustc_serialize/src/serialize.rs @@ -225,7 +225,7 @@ impl Encodable for NonZero { impl Decodable for NonZero { fn decode(d: &mut D) -> Self { - NonZero::::new(d.read_u32()).unwrap() + NonZero::new(d.read_u32()).unwrap() } } diff --git a/compiler/rustc_session/src/options.rs b/compiler/rustc_session/src/options.rs index 1a046667bd718..743f476033935 100644 --- a/compiler/rustc_session/src/options.rs +++ b/compiler/rustc_session/src/options.rs @@ -1007,7 +1007,7 @@ mod parse { } }, None => { - *slot = NonZero::::new(1); + *slot = NonZero::new(1); true } } diff --git a/library/alloc/src/collections/binary_heap/mod.rs b/library/alloc/src/collections/binary_heap/mod.rs index 3a82fb0df8833..c89a380628020 100644 --- a/library/alloc/src/collections/binary_heap/mod.rs +++ b/library/alloc/src/collections/binary_heap/mod.rs @@ -350,7 +350,7 @@ impl DerefMut for PeekMut<'_, T, A> { // the standard library as "leak amplification". unsafe { // SAFETY: len > 1 so len != 0. - self.original_len = Some(NonZero::::new_unchecked(len)); + self.original_len = Some(NonZero::new_unchecked(len)); // SAFETY: len > 1 so all this does for now is leak elements, // which is safe. self.heap.data.set_len(1); @@ -1576,8 +1576,8 @@ unsafe impl SourceIter for IntoIter { #[unstable(issue = "none", feature = "inplace_iteration")] #[doc(hidden)] unsafe impl InPlaceIterable for IntoIter { - const EXPAND_BY: Option> = NonZero::::new(1); - const MERGE_BY: Option> = NonZero::::new(1); + const EXPAND_BY: Option> = NonZero::new(1); + const MERGE_BY: Option> = NonZero::new(1); } unsafe impl AsVecIntoIter for IntoIter { diff --git a/library/alloc/src/collections/vec_deque/into_iter.rs b/library/alloc/src/collections/vec_deque/into_iter.rs index 02ab3f79b0641..692af7c197a30 100644 --- a/library/alloc/src/collections/vec_deque/into_iter.rs +++ b/library/alloc/src/collections/vec_deque/into_iter.rs @@ -63,7 +63,7 @@ impl Iterator for IntoIter { self.inner.drain(..n); 0 }; - NonZero::::new(rem).map_or(Ok(()), Err) + NonZero::new(rem).map_or(Ok(()), Err) } #[inline] @@ -192,7 +192,7 @@ impl DoubleEndedIterator for IntoIter { self.inner.truncate(len - n); 0 }; - NonZero::::new(rem).map_or(Ok(()), Err) + NonZero::new(rem).map_or(Ok(()), Err) } fn try_rfold(&mut self, mut init: B, mut f: F) -> R diff --git a/library/alloc/src/vec/into_iter.rs b/library/alloc/src/vec/into_iter.rs index 76d1b7b72a12f..63d8fe19ac35c 100644 --- a/library/alloc/src/vec/into_iter.rs +++ b/library/alloc/src/vec/into_iter.rs @@ -248,7 +248,7 @@ impl Iterator for IntoIter { unsafe { ptr::drop_in_place(to_drop); } - NonZero::::new(n - step_size).map_or(Ok(()), Err) + NonZero::new(n - step_size).map_or(Ok(()), Err) } #[inline] @@ -350,7 +350,7 @@ impl DoubleEndedIterator for IntoIter { unsafe { ptr::drop_in_place(to_drop); } - NonZero::::new(n - step_size).map_or(Ok(()), Err) + NonZero::new(n - step_size).map_or(Ok(()), Err) } } @@ -457,8 +457,8 @@ unsafe impl<#[may_dangle] T, A: Allocator> Drop for IntoIter { #[unstable(issue = "none", feature = "inplace_iteration")] #[doc(hidden)] unsafe impl InPlaceIterable for IntoIter { - const EXPAND_BY: Option> = NonZero::::new(1); - const MERGE_BY: Option> = NonZero::::new(1); + const EXPAND_BY: Option> = NonZero::new(1); + const MERGE_BY: Option> = NonZero::new(1); } #[unstable(issue = "none", feature = "inplace_iteration")] diff --git a/library/alloc/tests/vec.rs b/library/alloc/tests/vec.rs index e872ace883c03..04bb20e96b792 100644 --- a/library/alloc/tests/vec.rs +++ b/library/alloc/tests/vec.rs @@ -1089,9 +1089,9 @@ fn test_into_iter_advance_by() { assert_eq!(i.advance_back_by(1), Ok(())); assert_eq!(i.as_slice(), [2, 3, 4]); - assert_eq!(i.advance_back_by(usize::MAX), Err(NonZero::::new(usize::MAX - 3).unwrap())); + assert_eq!(i.advance_back_by(usize::MAX), Err(NonZero::new(usize::MAX - 3).unwrap())); - assert_eq!(i.advance_by(usize::MAX), Err(NonZero::::new(usize::MAX).unwrap())); + assert_eq!(i.advance_by(usize::MAX), Err(NonZero::new(usize::MAX).unwrap())); assert_eq!(i.advance_by(0), Ok(())); assert_eq!(i.advance_back_by(0), Ok(())); @@ -1192,7 +1192,7 @@ fn test_from_iter_specialization_with_iterator_adapters() { .map(|(a, b)| a + b) .map_while(Option::Some) .skip(1) - .map(|e| if e != usize::MAX { Ok(NonZero::::new(e)) } else { Err(()) }); + .map(|e| if e != usize::MAX { Ok(NonZero::new(e)) } else { Err(()) }); assert_in_place_trait(&iter); let sink = iter.collect::, _>>().unwrap(); let sinkptr = sink.as_ptr(); diff --git a/library/alloc/tests/vec_deque.rs b/library/alloc/tests/vec_deque.rs index 079750abd69fb..eda2f8bb812b5 100644 --- a/library/alloc/tests/vec_deque.rs +++ b/library/alloc/tests/vec_deque.rs @@ -445,9 +445,9 @@ fn test_into_iter() { assert_eq!(it.next_back(), Some(3)); let mut it = VecDeque::from(vec![1, 2, 3, 4, 5]).into_iter(); - assert_eq!(it.advance_by(10), Err(NonZero::::new(5).unwrap())); + assert_eq!(it.advance_by(10), Err(NonZero::new(5).unwrap())); let mut it = VecDeque::from(vec![1, 2, 3, 4, 5]).into_iter(); - assert_eq!(it.advance_back_by(10), Err(NonZero::::new(5).unwrap())); + assert_eq!(it.advance_back_by(10), Err(NonZero::new(5).unwrap())); } } diff --git a/library/core/src/array/iter.rs b/library/core/src/array/iter.rs index e50ae1b0d70af..e3d2cd2a31fbc 100644 --- a/library/core/src/array/iter.rs +++ b/library/core/src/array/iter.rs @@ -292,7 +292,7 @@ impl Iterator for IntoIter { ptr::drop_in_place(MaybeUninit::slice_assume_init_mut(slice)); } - NonZero::::new(remaining).map_or(Ok(()), Err) + NonZero::new(remaining).map_or(Ok(()), Err) } #[inline] @@ -347,7 +347,7 @@ impl DoubleEndedIterator for IntoIter { ptr::drop_in_place(MaybeUninit::slice_assume_init_mut(slice)); } - NonZero::::new(remaining).map_or(Ok(()), Err) + NonZero::new(remaining).map_or(Ok(()), Err) } } diff --git a/library/core/src/iter/adapters/array_chunks.rs b/library/core/src/iter/adapters/array_chunks.rs index 2e437b41dcebc..8c68ea114dbd2 100644 --- a/library/core/src/iter/adapters/array_chunks.rs +++ b/library/core/src/iter/adapters/array_chunks.rs @@ -255,7 +255,7 @@ where unsafe impl InPlaceIterable for ArrayChunks { const EXPAND_BY: Option> = I::EXPAND_BY; const MERGE_BY: Option> = const { - match (I::MERGE_BY, NonZero::::new(N)) { + match (I::MERGE_BY, NonZero::new(N)) { (Some(m), Some(n)) => m.checked_mul(n), _ => None, } diff --git a/library/core/src/iter/adapters/chain.rs b/library/core/src/iter/adapters/chain.rs index 7edfee7bf6c5f..bcaac2f42cf04 100644 --- a/library/core/src/iter/adapters/chain.rs +++ b/library/core/src/iter/adapters/chain.rs @@ -110,7 +110,7 @@ where // we don't fuse the second iterator } - NonZero::::new(n).map_or(Ok(()), Err) + NonZero::new(n).map_or(Ok(()), Err) } #[inline] @@ -196,7 +196,7 @@ where // we don't fuse the second iterator } - NonZero::::new(n).map_or(Ok(()), Err) + NonZero::new(n).map_or(Ok(()), Err) } #[inline] diff --git a/library/core/src/iter/adapters/cycle.rs b/library/core/src/iter/adapters/cycle.rs index 7919c040dba9b..b35ed8442032d 100644 --- a/library/core/src/iter/adapters/cycle.rs +++ b/library/core/src/iter/adapters/cycle.rs @@ -97,7 +97,7 @@ where }; } - NonZero::::new(n).map_or(Ok(()), Err) + NonZero::new(n).map_or(Ok(()), Err) } // No `fold` override, because `fold` doesn't make much sense for `Cycle`, diff --git a/library/core/src/iter/adapters/flatten.rs b/library/core/src/iter/adapters/flatten.rs index 42396157d863d..99344a88efc3f 100644 --- a/library/core/src/iter/adapters/flatten.rs +++ b/library/core/src/iter/adapters/flatten.rs @@ -200,7 +200,7 @@ where #[rustc_specialization_trait] #[unstable(issue = "none", feature = "inplace_iteration")] unsafe trait BoundedSize { - const UPPER_BOUND: Option> = NonZero::::new(1); + const UPPER_BOUND: Option> = NonZero::new(1); } #[unstable(issue = "none", feature = "inplace_iteration")] @@ -217,11 +217,11 @@ unsafe impl BoundedSize for Once {} unsafe impl BoundedSize for OnceWith {} #[unstable(issue = "none", feature = "inplace_iteration")] unsafe impl BoundedSize for [T; N] { - const UPPER_BOUND: Option> = NonZero::::new(N); + const UPPER_BOUND: Option> = NonZero::new(N); } #[unstable(issue = "none", feature = "inplace_iteration")] unsafe impl BoundedSize for array::IntoIter { - const UPPER_BOUND: Option> = NonZero::::new(N); + const UPPER_BOUND: Option> = NonZero::new(N); } #[unstable(issue = "none", feature = "inplace_iteration")] unsafe impl BoundedSize for Filter { @@ -680,9 +680,7 @@ where } match self.iter_try_fold(n, advance) { - ControlFlow::Continue(remaining) => { - NonZero::::new(remaining).map_or(Ok(()), Err) - } + ControlFlow::Continue(remaining) => NonZero::new(remaining).map_or(Ok(()), Err), _ => Ok(()), } } @@ -772,9 +770,7 @@ where } match self.iter_try_rfold(n, advance) { - ControlFlow::Continue(remaining) => { - NonZero::::new(remaining).map_or(Ok(()), Err) - } + ControlFlow::Continue(remaining) => NonZero::new(remaining).map_or(Ok(()), Err), _ => Ok(()), } } diff --git a/library/core/src/iter/adapters/skip.rs b/library/core/src/iter/adapters/skip.rs index 20a3b616f81e5..f51a2c39b8e28 100644 --- a/library/core/src/iter/adapters/skip.rs +++ b/library/core/src/iter/adapters/skip.rs @@ -154,7 +154,7 @@ where } } - NonZero::::new(n).map_or(Ok(()), Err) + NonZero::new(n).map_or(Ok(()), Err) } #[doc(hidden)] @@ -238,7 +238,7 @@ where let min = crate::cmp::min(self.len(), n); let rem = self.iter.advance_back_by(min); assert!(rem.is_ok(), "ExactSizeIterator contract violation"); - NonZero::::new(n - min).map_or(Ok(()), Err) + NonZero::new(n - min).map_or(Ok(()), Err) } } diff --git a/library/core/src/iter/adapters/take.rs b/library/core/src/iter/adapters/take.rs index e668e66253607..6870c677b1e07 100644 --- a/library/core/src/iter/adapters/take.rs +++ b/library/core/src/iter/adapters/take.rs @@ -125,7 +125,7 @@ where }; let advanced = min - rem; self.n -= advanced; - NonZero::::new(n - advanced).map_or(Ok(()), Err) + NonZero::new(n - advanced).map_or(Ok(()), Err) } } @@ -235,7 +235,7 @@ where let advanced_by_inner = advance_by - remainder; let advanced_by = advanced_by_inner - trim_inner; self.n -= advanced_by; - NonZero::::new(n - advanced_by).map_or(Ok(()), Err) + NonZero::new(n - advanced_by).map_or(Ok(()), Err) } } diff --git a/library/core/src/iter/range.rs b/library/core/src/iter/range.rs index 7a4748dcc0d8c..68937161e046a 100644 --- a/library/core/src/iter/range.rs +++ b/library/core/src/iter/range.rs @@ -678,7 +678,7 @@ impl RangeIteratorImpl for ops::Range { self.start = Step::forward_checked(self.start.clone(), taken).expect("`Step` invariants not upheld"); - NonZero::::new(n - taken).map_or(Ok(()), Err) + NonZero::new(n - taken).map_or(Ok(()), Err) } #[inline] @@ -719,7 +719,7 @@ impl RangeIteratorImpl for ops::Range { self.end = Step::backward_checked(self.end.clone(), taken).expect("`Step` invariants not upheld"); - NonZero::::new(n - taken).map_or(Ok(()), Err) + NonZero::new(n - taken).map_or(Ok(()), Err) } } @@ -766,7 +766,7 @@ impl RangeIteratorImpl for ops::Range { // Otherwise 0 is returned which always safe to use. self.start = unsafe { Step::forward_unchecked(self.start, taken) }; - NonZero::::new(n - taken).map_or(Ok(()), Err) + NonZero::new(n - taken).map_or(Ok(()), Err) } #[inline] @@ -807,7 +807,7 @@ impl RangeIteratorImpl for ops::Range { // SAFETY: same as the spec_advance_by() implementation self.end = unsafe { Step::backward_unchecked(self.end, taken) }; - NonZero::::new(n - taken).map_or(Ok(()), Err) + NonZero::new(n - taken).map_or(Ok(()), Err) } } diff --git a/library/core/src/iter/sources/repeat_n.rs b/library/core/src/iter/sources/repeat_n.rs index 77bb8372a446a..8224e4b12a0eb 100644 --- a/library/core/src/iter/sources/repeat_n.rs +++ b/library/core/src/iter/sources/repeat_n.rs @@ -145,7 +145,7 @@ impl Iterator for RepeatN { if skip > len { // SAFETY: we just checked that the difference is positive - Err(unsafe { NonZero::::new_unchecked(skip - len) }) + Err(unsafe { NonZero::new_unchecked(skip - len) }) } else { self.count = len - skip; Ok(()) diff --git a/library/core/src/iter/traits/double_ended.rs b/library/core/src/iter/traits/double_ended.rs index eb830256962e1..48aae73d928a0 100644 --- a/library/core/src/iter/traits/double_ended.rs +++ b/library/core/src/iter/traits/double_ended.rs @@ -138,7 +138,7 @@ pub trait DoubleEndedIterator: Iterator { for i in 0..n { if self.next_back().is_none() { // SAFETY: `i` is always less than `n`. - return Err(unsafe { NonZero::::new_unchecked(n - i) }); + return Err(unsafe { NonZero::new_unchecked(n - i) }); } } Ok(()) diff --git a/library/core/src/iter/traits/iterator.rs b/library/core/src/iter/traits/iterator.rs index 6df66e779c425..522e75a5683b2 100644 --- a/library/core/src/iter/traits/iterator.rs +++ b/library/core/src/iter/traits/iterator.rs @@ -337,7 +337,7 @@ pub trait Iterator { for i in 0..n { if self.next().is_none() { // SAFETY: `i` is always less than `n`. - return Err(unsafe { NonZero::::new_unchecked(n - i) }); + return Err(unsafe { NonZero::new_unchecked(n - i) }); } } Ok(()) diff --git a/library/core/src/num/nonzero.rs b/library/core/src/num/nonzero.rs index ddaffadf4bf7b..6410ff5f828b8 100644 --- a/library/core/src/num/nonzero.rs +++ b/library/core/src/num/nonzero.rs @@ -336,7 +336,7 @@ macro_rules! nonzero_integer { // SAFETY: // `self` is non-zero, which means it has at least one bit set, which means // that the result of `count_ones` is non-zero. - unsafe { NonZero::::new_unchecked(self.get().count_ones()) } + unsafe { NonZero::new_unchecked(self.get().count_ones()) } } nonzero_integer_signedness_dependent_methods! { diff --git a/library/core/src/ops/index_range.rs b/library/core/src/ops/index_range.rs index 2ba0bd158f74b..07ea2e930d57a 100644 --- a/library/core/src/ops/index_range.rs +++ b/library/core/src/ops/index_range.rs @@ -132,7 +132,7 @@ impl Iterator for IndexRange { #[inline] fn advance_by(&mut self, n: usize) -> Result<(), NonZero> { let taken = self.take_prefix(n); - NonZero::::new(n - taken.len()).map_or(Ok(()), Err) + NonZero::new(n - taken.len()).map_or(Ok(()), Err) } } @@ -150,7 +150,7 @@ impl DoubleEndedIterator for IndexRange { #[inline] fn advance_back_by(&mut self, n: usize) -> Result<(), NonZero> { let taken = self.take_suffix(n); - NonZero::::new(n - taken.len()).map_or(Ok(()), Err) + NonZero::new(n - taken.len()).map_or(Ok(()), Err) } } diff --git a/library/core/src/ptr/alignment.rs b/library/core/src/ptr/alignment.rs index ad22ee5a0271b..d2422bb80ae58 100644 --- a/library/core/src/ptr/alignment.rs +++ b/library/core/src/ptr/alignment.rs @@ -100,7 +100,7 @@ impl Alignment { #[inline] pub const fn as_nonzero(self) -> NonZeroUsize { // SAFETY: All the discriminants are non-zero. - unsafe { NonZero::::new_unchecked(self.as_usize()) } + unsafe { NonZero::new_unchecked(self.as_usize()) } } /// Returns the base-2 logarithm of the alignment. diff --git a/library/core/src/ptr/non_null.rs b/library/core/src/ptr/non_null.rs index 2246596a8832c..16e903439936d 100644 --- a/library/core/src/ptr/non_null.rs +++ b/library/core/src/ptr/non_null.rs @@ -295,7 +295,7 @@ impl NonNull { pub fn addr(self) -> NonZeroUsize { // SAFETY: The pointer is guaranteed by the type to be non-null, // meaning that the address will be non-zero. - unsafe { NonZero::::new_unchecked(self.pointer.addr()) } + unsafe { NonZero::new_unchecked(self.pointer.addr()) } } /// Creates a new pointer with the given address. diff --git a/library/core/src/slice/iter/macros.rs b/library/core/src/slice/iter/macros.rs index 53218391dcffd..7910981d0f5ee 100644 --- a/library/core/src/slice/iter/macros.rs +++ b/library/core/src/slice/iter/macros.rs @@ -200,7 +200,7 @@ macro_rules! iterator { let advance = cmp::min(len!(self), n); // SAFETY: By construction, `advance` does not exceed `self.len()`. unsafe { self.post_inc_start(advance) }; - NonZero::::new(n - advance).map_or(Ok(()), Err) + NonZero::new(n - advance).map_or(Ok(()), Err) } #[inline] @@ -425,7 +425,7 @@ macro_rules! iterator { let advance = cmp::min(len!(self), n); // SAFETY: By construction, `advance` does not exceed `self.len()`. unsafe { self.pre_dec_end(advance) }; - NonZero::::new(n - advance).map_or(Ok(()), Err) + NonZero::new(n - advance).map_or(Ok(()), Err) } } diff --git a/library/core/src/slice/mod.rs b/library/core/src/slice/mod.rs index c70a3d3224d04..1d8ac6aa04394 100644 --- a/library/core/src/slice/mod.rs +++ b/library/core/src/slice/mod.rs @@ -1086,7 +1086,7 @@ impl [T] { #[inline] #[track_caller] pub fn windows(&self, size: usize) -> Windows<'_, T> { - let size = NonZero::::new(size).expect("window size must be non-zero"); + let size = NonZero::new(size).expect("window size must be non-zero"); Windows::new(self, size) } diff --git a/library/core/src/str/iter.rs b/library/core/src/str/iter.rs index d2180fa83fb1e..00b4405faaefb 100644 --- a/library/core/src/str/iter.rs +++ b/library/core/src/str/iter.rs @@ -96,7 +96,7 @@ impl<'a> Iterator for Chars<'a> { unsafe { self.iter.advance_by(slurp).unwrap_unchecked() }; } - NonZero::::new(remainder).map_or(Ok(()), Err) + NonZero::new(remainder).map_or(Ok(()), Err) } #[inline] diff --git a/library/core/tests/array.rs b/library/core/tests/array.rs index 579c140c198c4..e7773d138c255 100644 --- a/library/core/tests/array.rs +++ b/library/core/tests/array.rs @@ -548,7 +548,7 @@ fn array_intoiter_advance_by() { assert_eq!(counter.get(), 13); let r = it.advance_by(123456); - assert_eq!(r, Err(NonZero::::new(123456 - 87).unwrap())); + assert_eq!(r, Err(NonZero::new(123456 - 87).unwrap())); assert_eq!(it.len(), 0); assert_eq!(counter.get(), 100); @@ -558,7 +558,7 @@ fn array_intoiter_advance_by() { assert_eq!(counter.get(), 100); let r = it.advance_by(10); - assert_eq!(r, Err(NonZero::::new(10).unwrap())); + assert_eq!(r, Err(NonZero::new(10).unwrap())); assert_eq!(it.len(), 0); assert_eq!(counter.get(), 100); } @@ -601,7 +601,7 @@ fn array_intoiter_advance_back_by() { assert_eq!(counter.get(), 13); let r = it.advance_back_by(123456); - assert_eq!(r, Err(NonZero::::new(123456 - 87).unwrap())); + assert_eq!(r, Err(NonZero::new(123456 - 87).unwrap())); assert_eq!(it.len(), 0); assert_eq!(counter.get(), 100); @@ -611,7 +611,7 @@ fn array_intoiter_advance_back_by() { assert_eq!(counter.get(), 100); let r = it.advance_back_by(10); - assert_eq!(r, Err(NonZero::::new(10).unwrap())); + assert_eq!(r, Err(NonZero::new(10).unwrap())); assert_eq!(it.len(), 0); assert_eq!(counter.get(), 100); } diff --git a/library/core/tests/iter/adapters/chain.rs b/library/core/tests/iter/adapters/chain.rs index 9e098d5bee442..b2429588de12b 100644 --- a/library/core/tests/iter/adapters/chain.rs +++ b/library/core/tests/iter/adapters/chain.rs @@ -34,10 +34,7 @@ fn test_iterator_chain_advance_by() { let mut iter = Unfuse::new(xs).chain(Unfuse::new(ys)); assert_eq!(iter.advance_by(i), Ok(())); assert_eq!(iter.next(), Some(&xs[i])); - assert_eq!( - iter.advance_by(100), - Err(NonZero::::new(100 - (len - i - 1)).unwrap()) - ); + assert_eq!(iter.advance_by(100), Err(NonZero::new(100 - (len - i - 1)).unwrap())); assert_eq!(iter.advance_by(0), Ok(())); } @@ -45,10 +42,7 @@ fn test_iterator_chain_advance_by() { let mut iter = Unfuse::new(xs).chain(Unfuse::new(ys)); assert_eq!(iter.advance_by(xs.len() + i), Ok(())); assert_eq!(iter.next(), Some(&ys[i])); - assert_eq!( - iter.advance_by(100), - Err(NonZero::::new(100 - (ys.len() - i - 1)).unwrap()) - ); + assert_eq!(iter.advance_by(100), Err(NonZero::new(100 - (ys.len() - i - 1)).unwrap())); assert_eq!(iter.advance_by(0), Ok(())); } @@ -58,7 +52,7 @@ fn test_iterator_chain_advance_by() { assert_eq!(iter.advance_by(0), Ok(())); let mut iter = xs.iter().chain(ys); - assert_eq!(iter.advance_by(len + 1), Err(NonZero::::new(1).unwrap())); + assert_eq!(iter.advance_by(len + 1), Err(NonZero::new(1).unwrap())); assert_eq!(iter.advance_by(0), Ok(())); } @@ -77,10 +71,7 @@ fn test_iterator_chain_advance_back_by() { let mut iter = Unfuse::new(xs).chain(Unfuse::new(ys)); assert_eq!(iter.advance_back_by(i), Ok(())); assert_eq!(iter.next_back(), Some(&ys[ys.len() - i - 1])); - assert_eq!( - iter.advance_back_by(100), - Err(NonZero::::new(100 - (len - i - 1)).unwrap()) - ); + assert_eq!(iter.advance_back_by(100), Err(NonZero::new(100 - (len - i - 1)).unwrap())); assert_eq!(iter.advance_back_by(0), Ok(())); } @@ -90,7 +81,7 @@ fn test_iterator_chain_advance_back_by() { assert_eq!(iter.next_back(), Some(&xs[xs.len() - i - 1])); assert_eq!( iter.advance_back_by(100), - Err(NonZero::::new(100 - (xs.len() - i - 1)).unwrap()) + Err(NonZero::new(100 - (xs.len() - i - 1)).unwrap()) ); assert_eq!(iter.advance_back_by(0), Ok(())); } @@ -101,7 +92,7 @@ fn test_iterator_chain_advance_back_by() { assert_eq!(iter.advance_back_by(0), Ok(())); let mut iter = xs.iter().chain(ys); - assert_eq!(iter.advance_back_by(len + 1), Err(NonZero::::new(1).unwrap())); + assert_eq!(iter.advance_back_by(len + 1), Err(NonZero::new(1).unwrap())); assert_eq!(iter.advance_back_by(0), Ok(())); } diff --git a/library/core/tests/iter/adapters/enumerate.rs b/library/core/tests/iter/adapters/enumerate.rs index 5aa7532c10cb2..b57d51c077e9b 100644 --- a/library/core/tests/iter/adapters/enumerate.rs +++ b/library/core/tests/iter/adapters/enumerate.rs @@ -66,7 +66,7 @@ fn test_iterator_enumerate_advance_by() { assert_eq!(it.next(), Some((2, &2))); assert_eq!(it.advance_by(2), Ok(())); assert_eq!(it.next(), Some((5, &5))); - assert_eq!(it.advance_by(1), Err(NonZero::::new(1).unwrap())); + assert_eq!(it.advance_by(1), Err(NonZero::new(1).unwrap())); assert_eq!(it.next(), None); } diff --git a/library/core/tests/iter/adapters/flatten.rs b/library/core/tests/iter/adapters/flatten.rs index fb6383b3289bb..2af7e0c388a3b 100644 --- a/library/core/tests/iter/adapters/flatten.rs +++ b/library/core/tests/iter/adapters/flatten.rs @@ -72,8 +72,8 @@ fn test_flatten_advance_by() { assert_eq!(it.advance_back_by(9), Ok(())); assert_eq!(it.next_back(), Some(25)); - assert_eq!(it.advance_by(usize::MAX), Err(NonZero::::new(usize::MAX - 9).unwrap())); - assert_eq!(it.advance_back_by(usize::MAX), Err(NonZero::::new(usize::MAX).unwrap())); + assert_eq!(it.advance_by(usize::MAX), Err(NonZero::new(usize::MAX - 9).unwrap())); + assert_eq!(it.advance_back_by(usize::MAX), Err(NonZero::new(usize::MAX).unwrap())); assert_eq!(it.advance_by(0), Ok(())); assert_eq!(it.advance_back_by(0), Ok(())); assert_eq!(it.size_hint(), (0, Some(0))); diff --git a/library/core/tests/iter/adapters/skip.rs b/library/core/tests/iter/adapters/skip.rs index 45726d158b608..8d5d06ad9fb3a 100644 --- a/library/core/tests/iter/adapters/skip.rs +++ b/library/core/tests/iter/adapters/skip.rs @@ -75,14 +75,14 @@ fn test_iterator_skip_nth() { #[test] fn test_skip_advance_by() { assert_eq!((0..0).skip(10).advance_by(0), Ok(())); - assert_eq!((0..0).skip(10).advance_by(1), Err(NonZero::::new(1).unwrap())); + assert_eq!((0..0).skip(10).advance_by(1), Err(NonZero::new(1).unwrap())); assert_eq!( (0u128..(usize::MAX as u128) + 1).skip(usize::MAX - 10).advance_by(usize::MAX - 5), - Err(NonZero::::new(usize::MAX - 16).unwrap()) + Err(NonZero::new(usize::MAX - 16).unwrap()) ); assert_eq!((0u128..u128::MAX).skip(usize::MAX - 10).advance_by(20), Ok(())); - assert_eq!((0..2).skip(1).advance_back_by(10), Err(NonZero::::new(9).unwrap())); + assert_eq!((0..2).skip(1).advance_back_by(10), Err(NonZero::new(9).unwrap())); assert_eq!((0..0).skip(1).advance_back_by(0), Ok(())); } diff --git a/library/core/tests/iter/adapters/take.rs b/library/core/tests/iter/adapters/take.rs index 6aa1b92954691..39afa2cbfcaf2 100644 --- a/library/core/tests/iter/adapters/take.rs +++ b/library/core/tests/iter/adapters/take.rs @@ -79,23 +79,23 @@ fn test_take_advance_by() { let mut take = (0..10).take(3); assert_eq!(take.advance_by(2), Ok(())); assert_eq!(take.next(), Some(2)); - assert_eq!(take.advance_by(1), Err(NonZero::::new(1).unwrap())); + assert_eq!(take.advance_by(1), Err(NonZero::new(1).unwrap())); assert_eq!((0..0).take(10).advance_by(0), Ok(())); - assert_eq!((0..0).take(10).advance_by(1), Err(NonZero::::new(1).unwrap())); - assert_eq!((0..10).take(4).advance_by(5), Err(NonZero::::new(1).unwrap())); + assert_eq!((0..0).take(10).advance_by(1), Err(NonZero::new(1).unwrap())); + assert_eq!((0..10).take(4).advance_by(5), Err(NonZero::new(1).unwrap())); let mut take = (0..10).take(3); assert_eq!(take.advance_back_by(2), Ok(())); assert_eq!(take.next(), Some(0)); - assert_eq!(take.advance_back_by(1), Err(NonZero::::new(1).unwrap())); + assert_eq!(take.advance_back_by(1), Err(NonZero::new(1).unwrap())); - assert_eq!((0..2).take(1).advance_back_by(10), Err(NonZero::::new(9).unwrap())); - assert_eq!((0..0).take(1).advance_back_by(1), Err(NonZero::::new(1).unwrap())); + assert_eq!((0..2).take(1).advance_back_by(10), Err(NonZero::new(9).unwrap())); + assert_eq!((0..0).take(1).advance_back_by(1), Err(NonZero::new(1).unwrap())); assert_eq!((0..0).take(1).advance_back_by(0), Ok(())); assert_eq!( (0..usize::MAX).take(100).advance_back_by(usize::MAX), - Err(NonZero::::new(usize::MAX - 100).unwrap()) + Err(NonZero::new(usize::MAX - 100).unwrap()) ); } diff --git a/library/core/tests/iter/range.rs b/library/core/tests/iter/range.rs index f840218382dae..9af07119a89a2 100644 --- a/library/core/tests/iter/range.rs +++ b/library/core/tests/iter/range.rs @@ -314,7 +314,7 @@ fn test_range_advance_by() { assert_eq!((r.start, r.end), (1, usize::MAX - 1)); - assert_eq!(Err(NonZero::::new(2).unwrap()), r.advance_by(usize::MAX)); + assert_eq!(Err(NonZero::new(2).unwrap()), r.advance_by(usize::MAX)); assert_eq!(Ok(()), r.advance_by(0)); assert_eq!(Ok(()), r.advance_back_by(0)); diff --git a/library/core/tests/iter/traits/iterator.rs b/library/core/tests/iter/traits/iterator.rs index 507f15c608832..93ef9c0812b16 100644 --- a/library/core/tests/iter/traits/iterator.rs +++ b/library/core/tests/iter/traits/iterator.rs @@ -152,14 +152,11 @@ fn test_iterator_advance_by() { let mut iter = v.iter(); assert_eq!(iter.advance_by(i), Ok(())); assert_eq!(iter.next().unwrap(), &v[i]); - assert_eq!( - iter.advance_by(100), - Err(NonZero::::new(100 - (v.len() - 1 - i)).unwrap()) - ); + assert_eq!(iter.advance_by(100), Err(NonZero::new(100 - (v.len() - 1 - i)).unwrap())); } assert_eq!(v.iter().advance_by(v.len()), Ok(())); - assert_eq!(v.iter().advance_by(100), Err(NonZero::::new(100 - v.len()).unwrap())); + assert_eq!(v.iter().advance_by(100), Err(NonZero::new(100 - v.len()).unwrap())); } #[test] @@ -170,14 +167,11 @@ fn test_iterator_advance_back_by() { let mut iter = v.iter(); assert_eq!(iter.advance_back_by(i), Ok(())); assert_eq!(iter.next_back().unwrap(), &v[v.len() - 1 - i]); - assert_eq!( - iter.advance_back_by(100), - Err(NonZero::::new(100 - (v.len() - 1 - i)).unwrap()) - ); + assert_eq!(iter.advance_back_by(100), Err(NonZero::new(100 - (v.len() - 1 - i)).unwrap())); } assert_eq!(v.iter().advance_back_by(v.len()), Ok(())); - assert_eq!(v.iter().advance_back_by(100), Err(NonZero::::new(100 - v.len()).unwrap())); + assert_eq!(v.iter().advance_back_by(100), Err(NonZero::new(100 - v.len()).unwrap())); } #[test] @@ -188,17 +182,11 @@ fn test_iterator_rev_advance_back_by() { let mut iter = v.iter().rev(); assert_eq!(iter.advance_back_by(i), Ok(())); assert_eq!(iter.next_back().unwrap(), &v[i]); - assert_eq!( - iter.advance_back_by(100), - Err(NonZero::::new(100 - (v.len() - 1 - i)).unwrap()) - ); + assert_eq!(iter.advance_back_by(100), Err(NonZero::new(100 - (v.len() - 1 - i)).unwrap())); } assert_eq!(v.iter().rev().advance_back_by(v.len()), Ok(())); - assert_eq!( - v.iter().rev().advance_back_by(100), - Err(NonZero::::new(100 - v.len()).unwrap()) - ); + assert_eq!(v.iter().rev().advance_back_by(100), Err(NonZero::new(100 - v.len()).unwrap())); } #[test] @@ -466,14 +454,11 @@ fn test_iterator_rev_advance_by() { let mut iter = v.iter().rev(); assert_eq!(iter.advance_by(i), Ok(())); assert_eq!(iter.next().unwrap(), &v[v.len() - 1 - i]); - assert_eq!( - iter.advance_by(100), - Err(NonZero::::new(100 - (v.len() - 1 - i)).unwrap()) - ); + assert_eq!(iter.advance_by(100), Err(NonZero::new(100 - (v.len() - 1 - i)).unwrap())); } assert_eq!(v.iter().rev().advance_by(v.len()), Ok(())); - assert_eq!(v.iter().rev().advance_by(100), Err(NonZero::::new(100 - v.len()).unwrap())); + assert_eq!(v.iter().rev().advance_by(100), Err(NonZero::new(100 - v.len()).unwrap())); } #[test] diff --git a/library/core/tests/nonzero.rs b/library/core/tests/nonzero.rs index 69dbe5d7dea23..d728513a4e297 100644 --- a/library/core/tests/nonzero.rs +++ b/library/core/tests/nonzero.rs @@ -4,7 +4,7 @@ use std::mem::size_of; #[test] fn test_create_nonzero_instance() { - let _a = unsafe { NonZero::::new_unchecked(21) }; + let _a = unsafe { NonZero::new_unchecked(21) }; } #[test] @@ -18,12 +18,12 @@ fn test_match_on_nonzero_option() { let a = Some(unsafe { NonZero::::new_unchecked(42) }); match a { Some(val) => assert_eq!(val.get(), 42), - None => panic!("unexpected None while matching on Some(NonZeroU32(_))"), + None => panic!("unexpected None while matching on Some(NonZero(_))"), } match unsafe { Some(NonZero::::new_unchecked(43)) } { Some(val) => assert_eq!(val.get(), 43), - None => panic!("unexpected None while matching on Some(NonZeroU32(_))"), + None => panic!("unexpected None while matching on Some(NonZero(_))"), } } @@ -93,7 +93,7 @@ mod atom { index: NonZero, // private } - pub const FOO_ATOM: Atom = Atom { index: unsafe { NonZero::::new_unchecked(7) } }; + pub const FOO_ATOM: Atom = Atom { index: unsafe { NonZero::new_unchecked(7) } }; } macro_rules! atom { @@ -113,21 +113,21 @@ fn test_match_nonzero_const_pattern() { #[test] fn test_from_nonzero() { - let nz = NonZero::::new(1).unwrap(); + let nz = NonZero::new(1).unwrap(); let num: u32 = nz.into(); assert_eq!(num, 1u32); } #[test] fn test_from_signed_nonzero() { - let nz = NonZero::::new(1).unwrap(); + let nz = NonZero::new(1).unwrap(); let num: i32 = nz.into(); assert_eq!(num, 1i32); } #[test] fn test_from_str() { - assert_eq!("123".parse::>(), Ok(NonZero::::new(123).unwrap())); + assert_eq!("123".parse::>(), Ok(NonZero::new(123).unwrap())); assert_eq!( "0".parse::>().err().map(|e| e.kind().clone()), Some(IntErrorKind::Zero) @@ -148,8 +148,8 @@ fn test_from_str() { #[test] fn test_nonzero_bitor() { - let nz_alt = NonZero::::new(0b1010_1010).unwrap(); - let nz_low = NonZero::::new(0b0000_1111).unwrap(); + let nz_alt = NonZero::new(0b1010_1010).unwrap(); + let nz_low = NonZero::new(0b0000_1111).unwrap(); let both_nz: NonZero = nz_alt | nz_low; assert_eq!(both_nz.get(), 0b1010_1111); @@ -171,7 +171,7 @@ fn test_nonzero_bitor() { fn test_nonzero_bitor_assign() { let mut target = NonZero::::new(0b1010_1010).unwrap(); - target |= NonZero::::new(0b0000_1111).unwrap(); + target |= NonZero::new(0b0000_1111).unwrap(); assert_eq!(target.get(), 0b1010_1111); target |= 0b0001_0000; @@ -183,11 +183,11 @@ fn test_nonzero_bitor_assign() { #[test] fn test_nonzero_from_int_on_success() { - assert_eq!(NonZero::::try_from(5), Ok(NonZero::::new(5).unwrap())); - assert_eq!(NonZero::::try_from(5), Ok(NonZero::::new(5).unwrap())); + assert_eq!(NonZero::::try_from(5), Ok(NonZero::new(5).unwrap())); + assert_eq!(NonZero::::try_from(5), Ok(NonZero::new(5).unwrap())); - assert_eq!(NonZero::::try_from(-5), Ok(NonZero::::new(-5).unwrap())); - assert_eq!(NonZero::::try_from(-5), Ok(NonZero::::new(-5).unwrap())); + assert_eq!(NonZero::::try_from(-5), Ok(NonZero::new(-5).unwrap())); + assert_eq!(NonZero::::try_from(-5), Ok(NonZero::new(-5).unwrap())); } #[test] @@ -204,15 +204,15 @@ fn nonzero_const() { // test that the methods of `NonZeroX>` are usable in a const context // Note: only tests NonZero - const NONZERO_U8: NonZero = unsafe { NonZero::::new_unchecked(5) }; + const NONZERO_U8: NonZero = unsafe { NonZero::new_unchecked(5) }; const GET: u8 = NONZERO_U8.get(); assert_eq!(GET, 5); - const ZERO: Option> = NonZero::::new(0); + const ZERO: Option> = NonZero::new(0); assert!(ZERO.is_none()); - const ONE: Option> = NonZero::::new(1); + const ONE: Option> = NonZero::new(1); assert!(ONE.is_some()); /* FIXME(#110395) @@ -323,7 +323,7 @@ fn nonzero_trailing_zeros() { #[test] fn test_nonzero_uint_div() { - let nz = NonZero::::new(1).unwrap(); + let nz = NonZero::new(1).unwrap(); let x: u32 = 42u32 / nz; assert_eq!(x, 42u32); @@ -331,7 +331,7 @@ fn test_nonzero_uint_div() { #[test] fn test_nonzero_uint_rem() { - let nz = NonZero::::new(10).unwrap(); + let nz = NonZero::new(10).unwrap(); let x: u32 = 42u32 % nz; assert_eq!(x, 2u32); diff --git a/library/core/tests/ptr.rs b/library/core/tests/ptr.rs index 8a0cf90d799c0..b3f7dfa1fb9c7 100644 --- a/library/core/tests/ptr.rs +++ b/library/core/tests/ptr.rs @@ -1050,9 +1050,8 @@ fn nonnull_tagged_pointer_with_provenance() { /// memory location. pub fn pointer(self) -> NonNull { // SAFETY: The `addr` guaranteed to have bits set in the Self::ADDRESS_MASK, so the result will be non-null. - self.0.map_addr(|addr| unsafe { - NonZero::::new_unchecked(addr.get() & Self::ADDRESS_MASK) - }) + self.0 + .map_addr(|addr| unsafe { NonZero::new_unchecked(addr.get() & Self::ADDRESS_MASK) }) } /// Consume this tagged pointer and produce the data it carries. @@ -1073,7 +1072,7 @@ fn nonnull_tagged_pointer_with_provenance() { // ADDRESS_MASK) will always be non-zero. This a property of the type and its // construction. self.0 = self.0.map_addr(|addr| unsafe { - NonZero::::new_unchecked((addr.get() & Self::ADDRESS_MASK) | data) + NonZero::new_unchecked((addr.get() & Self::ADDRESS_MASK) | data) }) } } diff --git a/library/core/tests/result.rs b/library/core/tests/result.rs index 758203408a86c..6c008ab2cb196 100644 --- a/library/core/tests/result.rs +++ b/library/core/tests/result.rs @@ -411,7 +411,7 @@ fn result_try_trait_v2_branch() { assert_eq!(Ok::(4).branch(), Continue(4)); assert_eq!(Err::(4).branch(), Break(Err(4))); - let one = NonZero::::new(1).unwrap(); + let one = NonZero::new(1).unwrap(); assert_eq!(Ok::<(), NonZero>(()).branch(), Continue(())); assert_eq!(Err::<(), NonZero>(one).branch(), Break(Err(one))); assert_eq!(Ok::, ()>(one).branch(), Continue(one)); diff --git a/library/core/tests/slice.rs b/library/core/tests/slice.rs index bb2c17a479e22..c5743eda3e802 100644 --- a/library/core/tests/slice.rs +++ b/library/core/tests/slice.rs @@ -147,7 +147,7 @@ fn test_iterator_advance_by() { } let mut iter = v.iter(); - assert_eq!(iter.advance_by(v.len() + 1), Err(NonZero::::new(1).unwrap())); + assert_eq!(iter.advance_by(v.len() + 1), Err(NonZero::new(1).unwrap())); assert_eq!(iter.as_slice(), &[]); let mut iter = v.iter(); @@ -169,7 +169,7 @@ fn test_iterator_advance_back_by() { } let mut iter = v.iter(); - assert_eq!(iter.advance_back_by(v.len() + 1), Err(NonZero::::new(1).unwrap())); + assert_eq!(iter.advance_back_by(v.len() + 1), Err(NonZero::new(1).unwrap())); assert_eq!(iter.as_slice(), &[]); let mut iter = v.iter(); diff --git a/library/proc_macro/src/bridge/symbol.rs b/library/proc_macro/src/bridge/symbol.rs index ae3c0fe018fb1..712f6b4545828 100644 --- a/library/proc_macro/src/bridge/symbol.rs +++ b/library/proc_macro/src/bridge/symbol.rs @@ -137,7 +137,7 @@ thread_local! { names: fxhash::FxHashMap::default(), strings: Vec::new(), // Start with a base of 1 to make sure that `NonZeroU32` works. - sym_base: NonZero::::new(1).unwrap(), + sym_base: NonZero::new(1).unwrap(), }); } diff --git a/library/std/src/sys/pal/hermit/thread.rs b/library/std/src/sys/pal/hermit/thread.rs index 789de7f41ff9a..fee80c02d4a6f 100644 --- a/library/std/src/sys/pal/hermit/thread.rs +++ b/library/std/src/sys/pal/hermit/thread.rs @@ -98,7 +98,7 @@ impl Thread { } pub fn available_parallelism() -> io::Result> { - unsafe { Ok(NonZero::::new_unchecked(abi::get_processor_count())) } + unsafe { Ok(NonZero::new_unchecked(abi::get_processor_count())) } } pub mod guard { diff --git a/library/std/src/sys/pal/sgx/abi/tls/mod.rs b/library/std/src/sys/pal/sgx/abi/tls/mod.rs index 5ee1621420e3a..6762a43b483a4 100644 --- a/library/std/src/sys/pal/sgx/abi/tls/mod.rs +++ b/library/std/src/sys/pal/sgx/abi/tls/mod.rs @@ -38,7 +38,7 @@ impl Key { } fn from_index(index: usize) -> Self { - Key(NonZero::::new(index + 1).unwrap()) + Key(NonZero::new(index + 1).unwrap()) } pub fn as_usize(self) -> usize { @@ -46,7 +46,7 @@ impl Key { } pub fn from_usize(index: usize) -> Self { - Key(NonZero::::new(index).unwrap()) + Key(NonZero::new(index).unwrap()) } } diff --git a/library/std/src/sys/pal/sgx/abi/usercalls/raw.rs b/library/std/src/sys/pal/sgx/abi/usercalls/raw.rs index 4f52bb474b168..943b771498f8f 100644 --- a/library/std/src/sys/pal/sgx/abi/usercalls/raw.rs +++ b/library/std/src/sys/pal/sgx/abi/usercalls/raw.rs @@ -195,7 +195,7 @@ macro_rules! enclave_usercalls_internal_define_usercalls { #[inline(always)] pub unsafe fn $f($n1: $t1, $n2: $t2, $n3: $t3, $n4: $t4) -> $r { ReturnValue::from_registers(stringify!($f), unsafe { do_usercall( - rtunwrap!(Some, NonZero::::new(Usercalls::$f as Register)), + rtunwrap!(Some, NonZero::new(Usercalls::$f as Register)), RegisterArgument::into_register($n1), RegisterArgument::into_register($n2), RegisterArgument::into_register($n3), @@ -211,7 +211,7 @@ macro_rules! enclave_usercalls_internal_define_usercalls { #[inline(always)] pub unsafe fn $f($n1: $t1, $n2: $t2, $n3: $t3) -> $r { ReturnValue::from_registers(stringify!($f), unsafe { do_usercall( - rtunwrap!(Some, NonZero::::new(Usercalls::$f as Register)), + rtunwrap!(Some, NonZero::new(Usercalls::$f as Register)), RegisterArgument::into_register($n1), RegisterArgument::into_register($n2), RegisterArgument::into_register($n3), @@ -227,7 +227,7 @@ macro_rules! enclave_usercalls_internal_define_usercalls { #[inline(always)] pub unsafe fn $f($n1: $t1, $n2: $t2) -> $r { ReturnValue::from_registers(stringify!($f), unsafe { do_usercall( - rtunwrap!(Some, NonZero::::new(Usercalls::$f as Register)), + rtunwrap!(Some, NonZero::new(Usercalls::$f as Register)), RegisterArgument::into_register($n1), RegisterArgument::into_register($n2), 0,0, @@ -242,7 +242,7 @@ macro_rules! enclave_usercalls_internal_define_usercalls { #[inline(always)] pub unsafe fn $f($n1: $t1) -> $r { ReturnValue::from_registers(stringify!($f), unsafe { do_usercall( - rtunwrap!(Some, NonZero::::new(Usercalls::$f as Register)), + rtunwrap!(Some, NonZero::new(Usercalls::$f as Register)), RegisterArgument::into_register($n1), 0,0,0, return_type_is_abort!($r) @@ -256,7 +256,7 @@ macro_rules! enclave_usercalls_internal_define_usercalls { #[inline(always)] pub unsafe fn $f() -> $r { ReturnValue::from_registers(stringify!($f), unsafe { do_usercall( - rtunwrap!(Some, NonZero::::new(Usercalls::$f as Register)), + rtunwrap!(Some, NonZero::new(Usercalls::$f as Register)), 0,0,0,0, return_type_is_abort!($r) ) }) diff --git a/library/std/src/sys/pal/sgx/rwlock.rs b/library/std/src/sys/pal/sgx/rwlock.rs index 87bebac37dac9..ebae1cff0ee17 100644 --- a/library/std/src/sys/pal/sgx/rwlock.rs +++ b/library/std/src/sys/pal/sgx/rwlock.rs @@ -53,8 +53,7 @@ impl RwLock { // Another thread has passed the lock to us } else { // No waiting writers, acquire the read lock - *rguard.lock_var_mut() = - NonZero::::new(rguard.lock_var().map_or(0, |n| n.get()) + 1); + *rguard.lock_var_mut() = NonZero::new(rguard.lock_var().map_or(0, |n| n.get()) + 1); } } @@ -68,8 +67,7 @@ impl RwLock { false } else { // No waiting writers, acquire the read lock - *rguard.lock_var_mut() = - NonZero::::new(rguard.lock_var().map_or(0, |n| n.get()) + 1); + *rguard.lock_var_mut() = NonZero::new(rguard.lock_var().map_or(0, |n| n.get()) + 1); true } } @@ -111,7 +109,7 @@ impl RwLock { mut rguard: SpinMutexGuard<'_, WaitVariable>>>, wguard: SpinMutexGuard<'_, WaitVariable>, ) { - *rguard.lock_var_mut() = NonZero::::new(rguard.lock_var().unwrap().get() - 1); + *rguard.lock_var_mut() = NonZero::new(rguard.lock_var().unwrap().get() - 1); if rguard.lock_var().is_some() { // There are other active readers } else { diff --git a/library/std/src/sys/pal/sgx/waitqueue/mod.rs b/library/std/src/sys/pal/sgx/waitqueue/mod.rs index 92ffec8d0b7d2..2d952b7ebbca3 100644 --- a/library/std/src/sys/pal/sgx/waitqueue/mod.rs +++ b/library/std/src/sys/pal/sgx/waitqueue/mod.rs @@ -252,7 +252,7 @@ impl WaitQueue { entry_guard.wake = true; } - if let Some(count) = NonZero::::new(count) { + if let Some(count) = NonZero::new(count) { Ok(WaitGuard { mutex_guard: Some(guard), notified_tcs: NotifiedTcs::All { count } }) } else { Err(guard) diff --git a/library/std/src/sys/pal/uefi/thread.rs b/library/std/src/sys/pal/uefi/thread.rs index f6f5b20a42135..3d8fa27251f01 100644 --- a/library/std/src/sys/pal/uefi/thread.rs +++ b/library/std/src/sys/pal/uefi/thread.rs @@ -46,7 +46,7 @@ impl Thread { pub fn available_parallelism() -> io::Result> { // UEFI is single threaded - Ok(NonZero::::new(1).unwrap()) + Ok(NonZero::new(1).unwrap()) } pub mod guard { diff --git a/library/std/src/sys/pal/unix/thread.rs b/library/std/src/sys/pal/unix/thread.rs index dd3c370667a1e..767f269dbea3d 100644 --- a/library/std/src/sys/pal/unix/thread.rs +++ b/library/std/src/sys/pal/unix/thread.rs @@ -338,7 +338,7 @@ pub fn available_parallelism() -> io::Result> { // some old MIPS kernels were buggy and zero-initialized the mask if // none was explicitly set. // In that case we use the sysconf fallback. - if let Some(count) = NonZero::::new(count) { + if let Some(count) = NonZero::new(count) { return Ok(count) } } @@ -351,7 +351,7 @@ pub fn available_parallelism() -> io::Result> { let count = cpus as usize; // Cover the unusual situation where we were able to get the quota but not the affinity mask let count = count.min(quota); - Ok(unsafe { NonZero::::new_unchecked(count) }) + Ok(unsafe { NonZero::new_unchecked(count) }) } } } else if #[cfg(any( @@ -375,7 +375,7 @@ pub fn available_parallelism() -> io::Result> { ) == 0 { let count = libc::CPU_COUNT(&set) as usize; if count > 0 { - return Ok(NonZero::::new_unchecked(count)); + return Ok(NonZero::new_unchecked(count)); } } } @@ -397,7 +397,7 @@ pub fn available_parallelism() -> io::Result> { } } libc::_cpuset_destroy(set); - if let Some(count) = NonZero::::new(count) { + if let Some(count) = NonZero::new(count) { return Ok(count); } } @@ -433,7 +433,7 @@ pub fn available_parallelism() -> io::Result> { } } - Ok(unsafe { NonZero::::new_unchecked(cpus as usize) }) + Ok(unsafe { NonZero::new_unchecked(cpus as usize) }) } else if #[cfg(target_os = "nto")] { unsafe { use libc::_syspage_ptr; @@ -441,7 +441,7 @@ pub fn available_parallelism() -> io::Result> { Err(io::const_io_error!(io::ErrorKind::NotFound, "No syspage available")) } else { let cpus = (*_syspage_ptr).num_cpu; - NonZero::::new(cpus as usize) + NonZero::new(cpus as usize) .ok_or(io::const_io_error!(io::ErrorKind::NotFound, "The number of hardware threads is not known for the target platform")) } } @@ -456,7 +456,7 @@ pub fn available_parallelism() -> io::Result> { return Err(io::const_io_error!(io::ErrorKind::NotFound, "The number of hardware threads is not known for the target platform")); } - Ok(NonZero::::new_unchecked(sinfo.cpu_count as usize)) + Ok(NonZero::new_unchecked(sinfo.cpu_count as usize)) } } else { // FIXME: implement on vxWorks, Redox, l4re diff --git a/library/std/src/sys/pal/windows/args.rs b/library/std/src/sys/pal/windows/args.rs index c3a4d4706996d..2ecfe088d107b 100644 --- a/library/std/src/sys/pal/windows/args.rs +++ b/library/std/src/sys/pal/windows/args.rs @@ -21,12 +21,12 @@ use crate::vec; use crate::iter; -/// This is the const equivalent to `NonZero::::new(n).unwrap()` +/// This is the const equivalent to `NonZero::new(n).unwrap()` /// /// FIXME: This can be removed once `Option::unwrap` is stably const. /// See the `const_option` feature (#67441). const fn non_zero_u16(n: u16) -> NonZero { - match NonZero::::new(n) { + match NonZero::new(n) { Some(n) => n, None => panic!("called `unwrap` on a `None` value"), } diff --git a/library/std/src/sys/pal/windows/thread.rs b/library/std/src/sys/pal/windows/thread.rs index 4f189944fb2b8..0f709e2ec7ba7 100644 --- a/library/std/src/sys/pal/windows/thread.rs +++ b/library/std/src/sys/pal/windows/thread.rs @@ -121,7 +121,7 @@ pub fn available_parallelism() -> io::Result> { io::ErrorKind::NotFound, "The number of hardware threads is not known for the target platform", )), - cpus => Ok(unsafe { NonZero::::new_unchecked(cpus) }), + cpus => Ok(unsafe { NonZero::new_unchecked(cpus) }), } } diff --git a/library/std/src/sys/pal/xous/thread.rs b/library/std/src/sys/pal/xous/thread.rs index 2cc1585650184..21f5954d6e2d2 100644 --- a/library/std/src/sys/pal/xous/thread.rs +++ b/library/std/src/sys/pal/xous/thread.rs @@ -134,7 +134,7 @@ impl Thread { pub fn available_parallelism() -> io::Result> { // We're unicore right now. - Ok(unsafe { NonZero::::new_unchecked(1) }) + Ok(unsafe { NonZero::new_unchecked(1) }) } pub mod guard { diff --git a/library/std/src/sys_common/wstr.rs b/library/std/src/sys_common/wstr.rs index 601ef3dd1505c..8eae160648502 100644 --- a/library/std/src/sys_common/wstr.rs +++ b/library/std/src/sys_common/wstr.rs @@ -26,7 +26,7 @@ impl WStrUnits<'_> { pub fn peek(&self) -> Option> { // SAFETY: It's always safe to read the current item because we don't // ever move out of the array's bounds. - unsafe { NonZero::::new(*self.lpwstr.as_ptr()) } + unsafe { NonZero::new(*self.lpwstr.as_ptr()) } } /// Advance the iterator while `predicate` returns true. diff --git a/library/std/src/thread/mod.rs b/library/std/src/thread/mod.rs index 0da3da23568ec..4f0f010984ab9 100644 --- a/library/std/src/thread/mod.rs +++ b/library/std/src/thread/mod.rs @@ -1188,7 +1188,7 @@ impl ThreadId { }; match COUNTER.compare_exchange_weak(last, id, Relaxed, Relaxed) { - Ok(_) => return ThreadId(NonZero::::new(id).unwrap()), + Ok(_) => return ThreadId(NonZero::new(id).unwrap()), Err(id) => last = id, } } @@ -1207,7 +1207,7 @@ impl ThreadId { *counter = id; drop(counter); - ThreadId(NonZero::::new(id).unwrap()) + ThreadId(NonZero::new(id).unwrap()) } } } diff --git a/src/tools/miri/src/borrow_tracker/mod.rs b/src/tools/miri/src/borrow_tracker/mod.rs index 4424595ea1cdf..45240edea455d 100644 --- a/src/tools/miri/src/borrow_tracker/mod.rs +++ b/src/tools/miri/src/borrow_tracker/mod.rs @@ -21,7 +21,7 @@ pub struct BorTag(NonZero); impl BorTag { pub fn new(i: u64) -> Option { - NonZero::::new(i).map(BorTag) + NonZero::new(i).map(BorTag) } pub fn get(&self) -> u64 { @@ -184,7 +184,7 @@ impl GlobalStateInner { borrow_tracker_method, next_ptr_tag: BorTag::one(), base_ptr_tags: FxHashMap::default(), - next_call_id: NonZero::::new(1).unwrap(), + next_call_id: NonZero::new(1).unwrap(), protected_tags: FxHashMap::default(), tracked_pointer_tags, tracked_call_ids, @@ -206,7 +206,7 @@ impl GlobalStateInner { if self.tracked_call_ids.contains(&call_id) { machine.emit_diagnostic(NonHaltingDiagnostic::CreatedCallId(call_id)); } - self.next_call_id = NonZero::::new(call_id.get() + 1).unwrap(); + self.next_call_id = NonZero::new(call_id.get() + 1).unwrap(); FrameState { call_id, protected_tags: SmallVec::new() } } diff --git a/src/tools/miri/src/concurrency/sync.rs b/src/tools/miri/src/concurrency/sync.rs index c3130c8a8f0b8..b948ecb834539 100644 --- a/src/tools/miri/src/concurrency/sync.rs +++ b/src/tools/miri/src/concurrency/sync.rs @@ -30,7 +30,7 @@ macro_rules! declare_id { impl SyncId for $name { // Panics if `id == 0`. fn from_u32(id: u32) -> Self { - Self(std::num::NonZero::::new(id).unwrap()) + Self(std::num::NonZero::new(id).unwrap()) } fn to_u32(&self) -> u32 { self.0.get() @@ -43,7 +43,7 @@ macro_rules! declare_id { // therefore, need to shift by one when converting from an index // into a vector. let shifted_idx = u32::try_from(idx).unwrap().checked_add(1).unwrap(); - $name(std::num::NonZero::::new(shifted_idx).unwrap()) + $name(std::num::NonZero::new(shifted_idx).unwrap()) } fn index(self) -> usize { // See the comment in `Self::new`. diff --git a/src/tools/miri/src/shims/foreign_items.rs b/src/tools/miri/src/shims/foreign_items.rs index f0e6e0374d287..bf90d1468bb0e 100644 --- a/src/tools/miri/src/shims/foreign_items.rs +++ b/src/tools/miri/src/shims/foreign_items.rs @@ -477,7 +477,7 @@ trait EvalContextExtPriv<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> { let [id, show_unnamed] = this.check_shim(abi, Abi::Rust, link_name, args)?; let id = this.read_scalar(id)?.to_u64()?; let show_unnamed = this.read_scalar(show_unnamed)?.to_bool()?; - if let Some(id) = std::num::NonZero::::new(id) { + if let Some(id) = std::num::NonZero::new(id) { this.print_borrow_state(AllocId(id), show_unnamed)?; } }