Skip to content

Temporarily revert to NonZeroUsize in rustc-abi to fix building on stable #125240

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions compiler/rustc_abi/src/layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ 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;

Expand All @@ -11,8 +10,8 @@ use tracing::debug;

use crate::{
Abi, AbiAndPrefAlign, Align, FieldsShape, IndexSlice, IndexVec, Integer, LayoutS, Niche,
Primitive, ReprOptions, Scalar, Size, StructKind, TagEncoding, TargetDataLayout, Variants,
WrappingRange,
NonZeroUsize, Primitive, ReprOptions, Scalar, Size, StructKind, TagEncoding, TargetDataLayout,
Variants, WrappingRange,
};

// A variant is absent if it's uninhabited and only has ZST fields.
Expand Down Expand Up @@ -328,7 +327,7 @@ pub trait LayoutCalculator {

Some(LayoutS {
variants: Variants::Single { index: VariantIdx::new(0) },
fields: FieldsShape::Union(NonZero::new(only_variant.len())?),
fields: FieldsShape::Union(NonZeroUsize::new(only_variant.len())?),
abi,
largest_niche: None,
align,
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_abi/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#![cfg_attr(feature = "nightly", feature(rustdoc_internals))]

use std::fmt;
use std::num::{NonZero, ParseIntError};
use std::num::{NonZeroUsize, ParseIntError};
use std::ops::{Add, AddAssign, Mul, RangeInclusive, Sub};
use std::str::FromStr;

Expand Down Expand Up @@ -1175,7 +1175,7 @@ pub enum FieldsShape<FieldIdx: Idx> {
Primitive,

/// All fields start at no offset. The `usize` is the field count.
Union(NonZero<usize>),
Union(NonZeroUsize),

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