1
Fork 0

Use generic NonZero internally.

This commit is contained in:
Markus Reiter 2024-01-29 23:59:09 +01:00
parent ee9c7c940c
commit 746a58d435
No known key found for this signature in database
GPG key ID: 245293B51702655B
144 changed files with 653 additions and 604 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};
@ -782,7 +782,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)]