Skip to content

Commit 36830f4

Browse files
committedJan 30, 2024
Use generic NonZero internally.
1 parent 5518eaa commit 36830f4

File tree

150 files changed

+660
-611
lines changed

Some content is hidden

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

150 files changed

+660
-611
lines changed
 

‎compiler/rustc_abi/src/layout.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use tracing::debug;
77

88
use crate::{
99
Abi, AbiAndPrefAlign, Align, FieldsShape, IndexSlice, IndexVec, Integer, LayoutS, Niche,
10-
NonZeroUsize, Primitive, ReprOptions, Scalar, Size, StructKind, TagEncoding, TargetDataLayout,
10+
NonZero, Primitive, ReprOptions, Scalar, Size, StructKind, TagEncoding, TargetDataLayout,
1111
Variants, WrappingRange,
1212
};
1313

@@ -324,7 +324,7 @@ pub trait LayoutCalculator {
324324

325325
Some(LayoutS {
326326
variants: Variants::Single { index: VariantIdx::new(0) },
327-
fields: FieldsShape::Union(NonZeroUsize::new(only_variant.len())?),
327+
fields: FieldsShape::Union(NonZero::<usize>::new(only_variant.len())?),
328328
abi,
329329
largest_niche: None,
330330
align,

‎compiler/rustc_abi/src/lib.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1+
#![cfg_attr(feature = "nightly", feature(generic_nonzero))]
12
#![cfg_attr(feature = "nightly", feature(step_trait))]
23
#![cfg_attr(feature = "nightly", allow(internal_features))]
34
#![cfg_attr(feature = "nightly", doc(rust_logo))]
45
#![cfg_attr(feature = "nightly", feature(rustdoc_internals))]
56

67
use std::fmt;
7-
use std::num::{NonZeroUsize, ParseIntError};
8+
use std::num::{NonZero, ParseIntError};
89
use std::ops::{Add, AddAssign, Mul, RangeInclusive, Sub};
910
use std::str::FromStr;
1011

@@ -1124,7 +1125,7 @@ pub enum FieldsShape<FieldIdx: Idx> {
11241125
Primitive,
11251126

11261127
/// All fields start at no offset. The `usize` is the field count.
1127-
Union(NonZeroUsize),
1128+
Union(NonZero<usize>),
11281129

11291130
/// Array/vector-like placement, with all fields of identical types.
11301131
Array { stride: Size, count: u64 },

0 commit comments

Comments
 (0)