1
Fork 0

Auto merge of #120486 - reitermarkus:use-generic-nonzero, r=dtolnay

Use generic `NonZero` internally.

Tracking issue: https://github.com/rust-lang/rust/issues/120257
This commit is contained in:
bors 2024-02-16 07:46:31 +00:00
commit 1be468815c
144 changed files with 636 additions and 628 deletions

View file

@ -5,7 +5,7 @@
//! to be const-safe.
use std::fmt::Write;
use std::num::NonZeroUsize;
use std::num::NonZero;
use either::{Left, Right};
@ -785,7 +785,7 @@ impl<'rt, 'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> ValueVisitor<'mir, 'tcx, M>
fn visit_union(
&mut self,
op: &OpTy<'tcx, M::Provenance>,
_fields: NonZeroUsize,
_fields: NonZero<usize>,
) -> InterpResult<'tcx> {
// Special check for CTFE validation, preventing `UnsafeCell` inside unions in immutable memory.
if self.ctfe_mode.is_some_and(|c| !c.allow_immutable_unsafe_cell()) {

View file

@ -7,7 +7,7 @@ use rustc_middle::ty;
use rustc_target::abi::FieldIdx;
use rustc_target::abi::{FieldsShape, VariantIdx, Variants};
use std::num::NonZeroUsize;
use std::num::NonZero;
use super::{InterpCx, MPlaceTy, Machine, Projectable};
@ -43,7 +43,7 @@ pub trait ValueVisitor<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>>: Sized {
}
/// Visits the given value as a union. No automatic recursion can happen here.
#[inline(always)]
fn visit_union(&mut self, _v: &Self::V, _fields: NonZeroUsize) -> InterpResult<'tcx> {
fn visit_union(&mut self, _v: &Self::V, _fields: NonZero<usize>) -> InterpResult<'tcx> {
Ok(())
}
/// Visits the given value as the pointer of a `Box`. There is nothing to recurse into.

View file

@ -11,6 +11,7 @@ Rust MIR: a lowered representation of Rust.
#![feature(assert_matches)]
#![feature(box_patterns)]
#![feature(decl_macro)]
#![feature(generic_nonzero)]
#![feature(let_chains)]
#![feature(slice_ptr_get)]
#![feature(never_type)]