diff options
Diffstat (limited to 'compiler/rustc_middle')
| -rw-r--r-- | compiler/rustc_middle/src/middle/stability.rs | 2 | ||||
| -rw-r--r-- | compiler/rustc_middle/src/mir/interpret/mod.rs | 2 | ||||
| -rw-r--r-- | compiler/rustc_middle/src/mir/interpret/pointer.rs | 2 | ||||
| -rw-r--r-- | compiler/rustc_middle/src/ty/consts/int.rs | 23 | ||||
| -rw-r--r-- | compiler/rustc_middle/src/ty/generic_args.rs | 5 | ||||
| -rw-r--r-- | compiler/rustc_middle/src/ty/layout.rs | 2 | ||||
| -rw-r--r-- | compiler/rustc_middle/src/ty/mod.rs | 5 |
7 files changed, 18 insertions, 23 deletions
diff --git a/compiler/rustc_middle/src/middle/stability.rs b/compiler/rustc_middle/src/middle/stability.rs index 15ef00629b9..2f624ab0527 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::<u32>::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 4ef02a86e30..903c83cc54e 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::<u64>::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 15e12c45679..e2767ee2989 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::<u64>::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 15f69d2333c..5d50510338c 100644 --- a/compiler/rustc_middle/src/ty/consts/int.rs +++ b/compiler/rustc_middle/src/ty/consts/int.rs @@ -161,14 +161,14 @@ impl<D: Decoder> Decodable<D> 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::<u8>::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::<u8>::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::<u8>::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::<u8>::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<u128>, size: Size) -> Option<Self> { let data = i.into(); if size.truncate(data) == data { - Some(Self { data, size: NonZero::<u8>::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::<u8>::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::<u8>::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<ScalarInt> for bool { impl From<char> for ScalarInt { #[inline] fn from(c: char) -> Self { - Self { - data: c as u128, - size: NonZero::<u8>::new(std::mem::size_of::<char>() as u8).unwrap(), - } + Self { data: c as u128, size: NonZero::new(std::mem::size_of::<char>() as u8).unwrap() } } } @@ -457,7 +454,7 @@ impl From<Single> for ScalarInt { #[inline] fn from(f: Single) -> Self { // We trust apfloat to give us properly truncated data. - Self { data: f.to_bits(), size: NonZero::<u8>::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<Double> for ScalarInt { #[inline] fn from(f: Double) -> Self { // We trust apfloat to give us properly truncated data. - Self { data: f.to_bits(), size: NonZero::<u8>::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 c931c2064b0..813a7a64daf 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<ty::Term<'tcx>> for GenericArg<'tcx> { impl<'tcx> GenericArg<'tcx> { #[inline] pub fn unpack(self) -> GenericArgKind<'tcx> { - let ptr = unsafe { - self.ptr.map_addr(|addr| NonZero::<usize>::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 d9fa99535b1..2b34f5daaf6 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::<usize>::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 3eea0d428ee..eea3624898c 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<I = TyCtxt<'tcx>>> Decodable<D> for Term<'tcx> { impl<'tcx> Term<'tcx> { #[inline] pub fn unpack(self) -> TermKind<'tcx> { - let ptr = unsafe { - self.ptr.map_addr(|addr| NonZero::<usize>::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. |
