1
Fork 0

Use generic NonZero.

This commit is contained in:
Markus Reiter 2024-04-21 21:45:18 +02:00
parent 7531eafa7e
commit bd8e565e16
No known key found for this signature in database
GPG key ID: 245293B51702655B
22 changed files with 83 additions and 82 deletions

View file

@ -2,6 +2,7 @@ use std::borrow::{Borrow, Cow};
use std::cmp;
use std::fmt::{self, Write};
use std::iter;
use std::num::NonZero;
use std::ops::Bound;
use std::ops::Deref;
@ -10,8 +11,8 @@ use tracing::debug;
use crate::{
Abi, AbiAndPrefAlign, Align, FieldsShape, IndexSlice, IndexVec, Integer, LayoutS, Niche,
NonZeroUsize, Primitive, ReprOptions, Scalar, Size, StructKind, TagEncoding, TargetDataLayout,
Variants, WrappingRange,
Primitive, ReprOptions, Scalar, Size, StructKind, TagEncoding, TargetDataLayout, Variants,
WrappingRange,
};
// A variant is absent if it's uninhabited and only has ZST fields.
@ -327,7 +328,7 @@ pub trait LayoutCalculator {
Some(LayoutS {
variants: Variants::Single { index: VariantIdx::new(0) },
fields: FieldsShape::Union(NonZeroUsize::new(only_variant.len())?),
fields: FieldsShape::Union(NonZero::new(only_variant.len())?),
abi,
largest_niche: None,
align,